Reputation: 6161
I have created an instance and its pem file named as demo.pem
,
But due to some security i have to change my old demo.pem
file with demos.pem
for the same instance.
I do not want to create new instance for changing pem file => Is it possible? | Help?
Upvotes: 1
Views: 1751
Reputation: 1210
chmod 400 yourNewPemName.pem
ssh-keygen -y -f yourNewPemName.pem > yourNewPemName.pub
cd ~ / .ssh
authorized_keys
file, with the contents of your public key contents generated above step 3Upvotes: 1
Reputation: 269330
It's worth understanding how keypairs work...
When logging into Linux using keypairs, you specify a username and a keypair, eg:
ssh -i demo.pem [email protected]
Linux then looks in the .ssh/authorized_keys
file belonging to that user, eg:
/home/users/ec2-user/.ssh/authorized_keys
If looks for the public key in that file that matches the private key used for login. It then does keypair magical stuff and determines whether to allow the person to login.
Therefore, to enable login on an instance using a new keypair:
~/.ssh/authorized_keys
file in the appropriate user's home directoryYou can have multiple keys in that file, which permit login via any of the authorized keypairs.
Upvotes: 4