Manually starting ssh-agent to use it in a (remote) terminal session

Posted on Thu 22 June 2017 in misc

ssh-agent can be used to unlock an ssh private key and therefore prevent having to enter the password multiple times. Usually your desktop environment does this for you. But if you're for example sshing into your workstation and then use ssh (e.g. for git or hg) your desktop environment won't help you. Here's how to start ssh-agent and unlock your private key:

> eval `ssh-agent -s`
> ssh-add

Now you can use the unlocked key to make ssh connections. And after your work is done here's how to kill ssh-agent and unlock the key again:

> ssh-agent -k