[Openstack-operators] keypair inserting not working with fedora16 image

Lloyd Dewolf lloydostack at gmail.com
Thu Nov 8 18:35:26 UTC 2012


On Mon, Oct 22, 2012 at 9:03 AM, Kashif Mohammad
<k.mohammad1 at physics.ox.ac.uk> wrote:
>
> I have prepared a fedora 16 image and installed cloud-init in it. After adding to glance, I can instantiate a instance from that image, assign a public ip to it and can log in into the image through ssh with password. But somehow keypair is not inserted into the image so I can not log in to the instance using ssh keys.
> .ssh/authorized_key file is blank. I also want to understand that how this works i.e how a instance fetch a user key pair from server.

We've had great success using http://boxgrinder.org/ for our Red Hat
family image creation including CentOS.


There is also Oz, <https://github.com/clalancette/oz/wiki>,
<https://github.com/rackerjoe/oz-image-build/>, but historically Oz
had a smaller community.


I won't recommend a manual solution, but it would look something like:

create file /etc/rc.d/rc.local
Insert the following into the file:
#!/bin/sh
mkdir -p /root/.ssh
chmod 700 /root/.ssh
curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
> /tmp/metadata-key 2>/dev/null
cat /tmp/metadata-key >> /root/.ssh/authorized_keys
chmod 0600 /root/.ssh/authorized_keys
restorecon /root/.ssh/authorized_keys
 rm -f /tmp/metadata-key

Give the file permissions:
chmod +x /etc/rc.d/rc.local

Related http://docs.openstack.org/trunk/openstack-compute/admin/content/metadata-service.html



Hope that helps,
--
@lloyddewolf
http://www.pistoncloud.com/



More information about the OpenStack-operators mailing list