auto find ssh keys - 08-12-20

I use to always pass a key when sshing ex:

$ ssh -i ~/.ssh/de2 travis@vxxxxxxxxxxxxxxxxxxx.megasrv.de

That can be a bit annoying. I know two fixes:

add private key to ssh-agent

$ ssh-add ~/.ssh/de2

Now when you ssh you need not include the -i ~/.ssh/de2 because the ssh-agent will find it automatically.

*note: this resets once you reboot

configure individual host

You can configure individual hosts to use a spefic private key my editing your ~/.ssh/config:

Host de2
    HostName vxxxxxxxxxxxxxxxxxxxx.megasrv.de
    User travis
    IdentityFile ~/.ssh/de2

Now you only need to

$ ssh de2

source – https://www.techrepublic.com/article/how-to-use-per-host-ssh-configuration/

\- [ ssh ]