I'm always running ssh
with the -i
parameter and it's a hassle to always type in the correct key for whatever host I'm connecting to.
Is there a config file or something (on Mac) to define which private key to use when connecting to a particular host?
Best Answer
Yes, you want to create a
~/.ssh/config
file. That lets you define a shortcut name for a host, the username you want to connect as, and which key to use. Here's part of mine, with hostnames obfuscated:With this I can say,
ssh tabs
and get connected to host tabs.com as userme
, with keynew_rsa
, as though I'd usedssh me@tabs.com -i ~/.ssh/new_rsa
.