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 >> server.pub
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 server.pub firstname.lastname@example.org
Where “server.pub” is the public key, “sathish” is the username of server which you want to update the credentials/keys and “server1901.w3boostrap.com” is the server name.
After updating it, you can login with new credentials
# ssh -i server.pem email@example.com