Apple - Cannot unlock password protected SSH key in OS X Mavericks

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

I had the same problem. I solved it by moving .ssh/authorized_keys2 to .ssh/authorized_keys.

The file /etc/sshd_config explicitly contains these lines:

\# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
\# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  .ssh/authorized_keys

This is a change from previous macosx version?


Using brew openssl and openssh fixes the PCKS#8 issue on Mavericks.

brew update
brew install openssl
brew link openssl --force
brew install openssh

# confirm correct bins are being used
# both should be located in /usr/local/bin
which openssl
which openssh

# add key back to keychain
ssh-add ~/.ssh/id_rsa

I'm not sure if force linking openssl breaks anything on Mavricks. So far, I haven't noticed any issues.