I'm trying to use ssh to log in to AWS from OSX Mavericks and having a hell of a time:

I enter:

ssh -i ~/.ssh/filename.pem ec2-user@ec2-xx-x-xxx-xx.compute-1.amazonaws.com -v

And I get this, as well as a keychain popup that asks for a password, even though there is none to give...

debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Saving password to keychain failed.

I launched a new instance on AWS and generated a new key pair. When I left the .pem file unprotected, the OSX keychain popup didn't appear, but I was unable to access AWS because the file was unprotected:

Permissions 0644 for '/Users/cvn/.ssh/chris-test.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /Users/cvn/.ssh/chris-test.pem Permission denied (publickey).

So I ran

chmod 400 chris-test.pem

and the Keychain returned asking for a password that I do not have...

  • What command did you use to generate your key pair? Are you sure you didn't protect the private key .pem with a password? It's bad form to store private keys unencrypted, so you probably did give it a password.
    – Spiff
    Jun 3, 2015 at 4:17
  • On second thought, from that error message, maybe it's trying to store your private key in your OS X keychain, but your keychain is locked so it needs your keychain password to unlock it so it can store your private key there.
    – Spiff
    Jun 3, 2015 at 4:21
  • Hi Spiff - Thanks for the ideas. I've tried fixing this (see above) and no luck so far...
    – Chris
    Jun 8, 2015 at 22:42
  • Figured this out. It was a screwed RSA file. Thanks for the help.
    – Chris
    Jun 18, 2015 at 22:47

1 Answer 1


I had this issue when I by mistake used public key instead of private one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.