SSH into an AWS EC2 Instance

MD
R
Markdown

Re-gain SSH access to an EC2 instance when the keys were lost. Note: the keys are only downloadable on the first instance

List all identities

ssh-add -l

# SSH into AWS EC2 Instance With Your PEM File cp mykey.pem ~/.ssh/ chmod 600 mykey.pem ssh root@XX.XX.XXX.XXX -i ~/.ssh/mykey.pem ssh ubuntu@XX.XX.XXX.XXX -i ~/.ssh/mykey.pem ssh-add ~/.ssh/mykey.pem

# SSH into AWS EC2 Instance Without Your PEM File

  1. Stop instance
  2. Actions > Create new image (EBS)
  3. Check Images (left panel)
  4. Instances > Launch New Instance > Choose AMI 4.1 Create a new pair of keys
  5. Download new key pair sudo chmod -R 600 mykey.pem
  6. Access via SSH ssh -i mykey.pem core@10.0.0.23

Created on 10/6/2017