How to make ssh-agent automatically add the key on demand?

Posted by Vi. on Super User See other posts from Super User or by Vi.
Published on 2011-08-20T17:27:09Z Indexed on 2012/09/08 21:41 UTC
Read the original article Hit count: 279

Filed under:
|

I want to run ssh-agent (with maximum lifetime option), but not add any keys at startup, but instead add them on demand.

Like first time I login to some server it should ask for passphrase, next time (unless I waited for more than a hour) it should connect cleanly:

ssh server1
Enter passphrase for key '/home/vi/.ssh/id_dsa':
server1> ...

ssh server2
server2> # no passphrase this time

# wait for lifetime

ssh server2
Enter passphrase for key '/home/vi/.ssh/id_dsa':

I don't want to manually remember about running 'ssh-add' each time. (e.g. entered passphrase for just for ssh and "Oh, it hasn't remembered, need to retype").

How to configure ssh to automatically add key to ssh-agent if user provided the passphrase?

© Super User or respective owner

Related posts about ssh

Related posts about ssh-agent