Recently I wanted to connect to some remote server using different ssh keys. With the right
~/.ssh/config file this is easy and comfortable.
IdentityFile ~/.ssh/%h/%r/id_rsa IdentityFile ~/.ssh/%h/id_rsa IdentityFile ~/.ssh/id_rsa
%h and %r are placeholder for host and remote-user.
ssh foo@bar will first check if
~/.ssh/bar/foo/id_rsa exists, next
~/.ssh/bar/id_rsa and finally
Host github HostName 123.45.678.90 User myuser IdentityFile ~/.ssh/123.45.678.90/id_rsa
ssh email@example.com the above config allows you to simply type
You don’t need to remember all your IPs and remote-users any longer. For me this is a big time saver.
Please let me know if you have questions or suggestions. Either per @leifhanack or comment here.