Search code examples
amazon-web-servicessshamazon-ec2ubuntu-server

copy key pair to amazon


I have run into trouble

I have ec2 instance. I connected to it via ssh. I wanted to set up POST hook for git. And accidentally removed authorised_keys from /.ssh directory

My question is : if I am still connected to my aws instance can I copy myKey.pem to /.ssh directory ?

I want to omit instance restore process

Thank you in advance !))


Solution

  • If you can't find the public key that corresponds to your current .pem file, just generate a new key pair, and add that public key to your ~/.ssh/authorized_keys file! You could use AWS to generate the new key pair, or check out these popular instructions from GitHub: help.github.com/articles/generating-ssh-keys.