Ask Your Question

Change in keypair with which instace was created

asked 2016-10-07 10:35:36 -0500

Sanil gravatar image

updated 2016-10-10 13:30:51 -0500


I have around 40 instances created with one keypair. Now there is a requirement to rotate the key. Request guidance on any possible options to change the keypair with which the instance was created in openstack to use a new one without doing a rebuild.

Adding to the question, if the solution is to update a new key to all the servers, is there anyway to attach the new key to openstack setup as it still points to the old key.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-10-07 16:44:25 -0500

carlosedp gravatar image

updated 2016-10-07 16:45:16 -0500

If you still have that actual keypair working, you could create a script that executes ssh commands into each instance, injects the new key into ~/.ssh/authorized_keys and then remove the old key.

Something like:

ssh user@server echo "NEW KEY" >> ~/.ssh/authorized_keys
ssh user@server "sed -i.bak '/OLD KEY/d' ~/.ssh/authorized_keys"

You could create a list of all instance IPs you have or fetch the instance IPs using Openstack API though this would be more advanced.

edit flag offensive delete link more


Thanks Carlos, just to clarify with this process, is there anyway to attach this newkey to openstack setup so that it realizes it uses the new key.

Sanil gravatar imageSanil ( 2016-10-10 13:20:15 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-10-07 10:35:36 -0500

Seen: 803 times

Last updated: Oct 10 '16