Apple - Password dialog appears when SSH private key permissions are set to 0600

First, run ssh-add -K and check whether this fixes your problem.

If not:

  • Removed the rsa_id.pub file and regenerated a new one (must be in ~/.ssh/):

    ssh-keygen -y -f id_rsa > id_rsa.pub
    
  • Ensured permissions were set to 600 for both id_rsa and id_rsa.pub (must be in ~/.ssh/):

    chmod 600 id_rsa*
    
  • Ran the following command:

    ssh-add -K
    

After doing this, I was no longer prompted to give my private key password. This appears to actually put the private key password in the correct keychain location for OS X to use.


Make sure you have a corresponding id_rsa.pub or id_dsa.pub in your ~/.ssh directory.

When I had an id_rsa but not a corresponding id_rsa.pub, Mac OS X kept popping up the dialog and remember passowrd in my keychain did nothing.

cd ~/.ssh
ssh-keygen -y -f id_rsa > id_rsa.pub

generated the appropriate public key file for me.

If you already had your public file there (rename it to another name) and generate the public key again using the above command, you'll notice that the generated and the old one are not equal. Somehow the older versions of Mac OS X generated a public key that Lion does not like anymore, generating it again fixes that.

For the curious, the key is exactly the same, the part that changes is that there is no "comments" section after the key on the file any longer.


In my case ssh-add -K didn't do the trick, I had to specify the key:

ssh-add ~/.ssh/id_rsa