How to change the security key of AWS EC2 instance

Please share it on

Changing server passwords in a certain time period is a good security practice. In case of security key, you need to update it in some use cases. Here I’m talking about updating aws ec2 security key to the existing ec2 instance. Create a new EC2 security key from amazon ec2 console.


# ssh-keygen -y -f server.pem >>

Here “server.pem” is the newly generated private key and you can generate public key from the private key by using above command.

# ssh-copy-id -i

Where “” is the public key, “sathish” is the username of server which you want to update the credentials/keys and “” is the server name.

After updating it, you can login with new credentials

# ssh -i server.pem

Please share it on

Leave a Reply

Your email address will not be published. Required fields are marked *