How to make ssh-agent automatically add the key on demand?
- by Vi.
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?