Ask Your Question
1

Is it possible to associate key-pair at VM runtime?

asked 2015-10-19 00:33:22 -0500

Nodir gravatar image

Hello,

I know It is possible to associate key-pair during VM boot. I was wondering if it is possible after VM boot as well (during runtime). My understanding is that cloud-nit (running inside VM) fetches key-pair from metadata service and injects to the VM. Is possible to trigger this mechanism after boot, as well? It is very useful feature to have.

Thanks,

Nodir

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-10-23 07:48:57 -0500

Vinoth gravatar image

Openstack have no option to inject keypair after the VM is created. But we can try in another way if we have access to hypervisor (KVM).

login into the compute node where your VM is running.

       $ virsh list
       $ virsh suspend <vm id>
       $ cd /var/lib/nova/instances/<instance id folder>
       $ qemu-nbd -c /dev/nbd0 `pwd`/disk
       $ mount /dev/nbd0p1 /mnt/

       $ cp ~/.ssh/id_rsa.pub /mnt/ubuntu/.ssh/authorized_keys
       $ umount /mnt
       $ qemu-nbd -d /dev/nbd0
       $ virsh resume 30

Now you could use this id_rsa.pub as your keypair.

P.S:- I never tried this method yet :-)

Ref:- http://docs.openstack.org/openstack-o...

edit flag offensive delete link more

Comments

Thanks, Vinoth!

I don't think manually mounting VM volume for keypair injection is an ideal solution. But I'll give it a try see if it actually works.

Nodir gravatar imageNodir ( 2015-10-23 12:03:44 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

2 followers

Stats

Asked: 2015-10-19 00:33:22 -0500

Seen: 101 times

Last updated: Oct 23 '15