Cannot unlock password protected SSH key in OS X Mavericks I just upgraded to OSX 10.9, and when trying to establish an SSH connection with public key authentication, a prompt appears asking for my SSH key password.

I initially thought that the upgrade caused the keychain to forget some passwords, so I re-entered mine. Apparently, that wasn't the cause, because the prompt kept reappearing.

I first though that I may be using the wrong password, but while the following command:

$ ssh-keygen -vvv -y -f id_rsa &gt;| id_rsa.pub
debug3: Incorrect RSA1 identifier
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type &lt;unknown&gt;
Enter passphrase:
debug3: Incorrect RSA1 identifier
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type &lt;unknown&gt;
load failed


...does not work! If I try to use openssl:

$ openssl rsa -in id_rsa -text
Enter pass phrase for id_rsa:
Private-Key: (2048 bit)
modulus:
    00:...


my private key is correctly decrypted and all information is printed.

What happened with the upgrade to Mavericks? How can I get my private key back in a usable state?
Apparently, the private key I was using on my machine was an old one. My key did not contain the encryption information added to the private key file if I generate a new one:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-...


To solve the problem, I decrypted the key with openssl:

$ cd ~/.ssh
$ cp id_rsa id_rsa.bck
$ openssl rsa -in id_rsa -out id_rsa


...and then re-encrypted it:

$ openssl rsa -in id_rsa -aes256 -out id_rsa
$ chmod 0600 id_rsa


And just in case, regenerate the public key as well:

$ ssh-keygen -y -f id_rsa &gt; id_rsa.pub