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...

  • Sounds like the format of your pem file is wrong. Check that you've got all of the required content. Running SSH with debug switches might give a clue (-d -d-d) Jun 9 '15 at 6:39
  • did you ever figure this out? same issue...
    – ambe5960
    Nov 10 '15 at 22:21

In my case private key was in openssh format (line -----BEGIN OPENSSH PRIVATE KEY----- in key file to check), but client ssh works only with rsa format (-----BEGIN RSA PRIVATE KEY----- line). I'd just converted one to another and it works. See how to convert Openssh Private Key to RSA Private Key here.


Make sure you're really using private key (not a public one, not something else) and double-check its content.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – Dave M
    Mar 29 '17 at 21:32
  • @DaveM now it's better?
    – Putnik
    Mar 30 '17 at 18:44

In my case, removing the line IdentitiesOnly=yes from my ~/.ssh/config file solved the issue.

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.