0

I've been working with AWS for awhile and I am not sure exactly happened but after returning to my computer after a week away from AWS there is something wrong with my key pair permissions. Key pairs have never been an issue but when trying to SSH into EC2 instances, I am always getting one of two errors:

Failed to add the host to the list of known hosts

Followed by

Permission denied (publickey).

OR

I am prompted for an instance-specific password

Ironically, this comes after the initial prompt ensuring you want to connect. I've tried generating key pairs 3 ways.

1) AWS Console 2) At Launch 3) Terminal

I've imported keys and just tried using plain key pairs created in the console and if I don't get a public key error, I am prompted for a password for the instance which I do not have. I am currently preparing for an AWS certification exam so this is obviously a problem I've been dealing with for about a day now and I'm out of ideas troubleshooting wise.

Any help would be greatly appreciated.

4
  • Think you could throw in the output from ssh -v? Obviously scrub sensitive data first. The message Failed to add the host to the list of known hosts points to a file permission issue on ~/.ssh/known_hosts on your local machine. It can usually be ignored but may point to other permission issues on your ssh directory which prevent the use of your keys when connecting. The verbose output will help diagnose that.
    – Foosh
    Dec 27, 2017 at 18:10
  • usage: ssh [-123XXXXXXXXXXXXX] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q cipher | cipher-auth | mac | kex | key] [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command] Dec 27, 2017 at 18:26
  • Your help is much appreciated this has been driving me insane for two days now whenever an exercise comes up involving SSH I just have to skip it until I figure out how to fix whatever permission issue was caused and find out what caused it. Dec 27, 2017 at 18:28
  • Sorry, I meant to add a -v to the ssh command you use to connect to aws. i.e. ssh -v [email protected]
    – Foosh
    Dec 27, 2017 at 22:40

1 Answer 1

0

Change the permission of your key by using chmod command. Use 400 permission for the pem file and try it again. Also make sure that you opened your public IP to access the machine.

2
  • Can you explain why you think changing the permissions on the key file will work?
    – bertieb
    Jul 31, 2018 at 11:51
  • PEM file has to be in 400 permission. Then only it will work. You can check in the net about this.
    – Gurumahesh
    Jul 31, 2018 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .