Ask Your Question
0

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

Hi,

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.

Thanks,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

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

Comments

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

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

1 follower

Stats

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

Seen: 376 times

Last updated: Oct 10 '16