4

When connecting to the server with ssh I'm prompted for a passphrase, although the creator of the key hasn't set one and the file is a plain text private key.

$ cat ~/.ssh/private.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEowfIBAdfsdf34325...
-----END RSA PRIVATE KEY——

I also tried to reset the passphrase with

$ ssh-keygen -p -f ~/.ssh/private.pem -P ''
Bad passphrase.

$ ssh -vvvv -i ~/.ssh/private.pem HOST
debug2: key: /Users/.../private.pem (0x0), explicit
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/.../private.pem
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/Users/.../private.pem':
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

After trying arzyfex's solution ssh-add returns 1 as exit code, without any explanation.

$ ssh-agent bash
$ ssh-add  ~/.ssh/private.pem
$ Enter passphrase for /Users/../private.pem:
1 $
2
  • what message you get when you do ssh remotehost ?
    – Rahul
    May 5, 2016 at 12:15
  • @arzyfex updated the question
    – dimid
    May 5, 2016 at 12:21

1 Answer 1

5

There is upstream bug discussion this problem. Currently, openssh interprets all the errors from parsing keys in openssl as "wrong passphrase". The patch is available and it will hopefully make it to the next release.

Specifically to your problem, it looks like somehow broken key. How did you get it? From your question, I see:

-----END RSA PRIVATE KEY——

The ending is certainly not valid and it might get formatted by some "clever" editor. Try to fix it back to the ----- and give it one more try.

1
  • Wow, it worked, thanks! I can't believe I missed such a simple problem.
    – dimid
    May 5, 2016 at 13:01

You must log in to answer this question.

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