ssh-agent on MAC OS X Lion - sometimes it requests ssh password

Terminal V. 2.2.2

Mac OS X Lion 10.7.3

I've followed ipsis verbis the steps here:

https://superuser.com/a/8110/72002

This works, BUT, if I restart the machine, it promps for the password again!!!

I even add one more, just to make sure it works:

ssh-agent bash

ssh-add ~/.ssh/mykeywithoutextention

#Restart terminal

It stills asks for the password after restart!!

It seems that, as posted here: http://alchemycs.com/2011/08/mac-os-x-lion-terminal-and-ssh-how-to-start-ssh-agent-at-login/

when Mac OS X boots back up and starts Terminal.app at login,ssh-agent is not started before Terminal.app starts

Does anyone have a clue about that could be the issue here and how can we properly solve this?


Solution 1:

On OS X Lion, ssh-agent is configured to start at boot by default. And ssh-agent will always load your default keys (~/.ssh/id_rsa and ~/.ssh/id_dsa). If you have multiple ssh keys (I have one for each client/project) and want ssh-agent to remember them across restarts:

ssh-add -K ~/.ssh/your-other-key

I give mine an expiration as well, although honestly, I don't know if it matters, since the -K adds it to keychain and I believe the expiration is just the agent. Anyway:

ssh-add -K -t 7776000 ~/.ssh/my-other-key