so

AddKeysToAgent

Volume 7, Issue 24; 06 Apr 2023

TIL: You can configure SSH to automatically ask for keys and add them to SSH agent.

If you use SSH, I hope you know about ssh-agent. If you don’t, start there. In brief: ssh-agent remembers your SSH passwords, so you don’t have to type them over and over again. I use ssh to connect to other hosts and to connect to most of my github repositories. If I had to type my SSH passphrase every time I wanted to fetch or push, I’d go mad.

To use ssh-agent, you have to start it and then add your keys to it. On modern systems, the agent seems to start up automatically, which is nice.

I’ve experimented with various ways of getting my keys into it when I first login, but just learned that if you put this at the top of your ~/.ssh/config file,

Host *
  AddKeysToAgent yes

the first time you try to use SSH, it’ll ask for your passphrase and then store it in the agent.

No more fussing about at the start of a session, no fussing at all if I login and happen never to use SSH on that host. Win!

#TIL