SSH config
Connecting to servers with SSH often will pretty fast turn in to a tedious task especially if you, like me, connecting with different users on different IP addresses with different keys. I do this almost daily.
Luckily there is a very nice solution and that’s the SSH configuration file where you can define all of this so you don’t need to remember everything all the time.
Config file
It’s a very simple configuration and the configuration file lives in ~/.ssh/config
. You can create the file if it’s not already there.
The format looks like this:
Host <alias>
Hostname <domain or ip>
User <username>
Identityfile </path/to/key>
Host
: Alias for your host. It will let you use this alias instead of IP/domain to connect. I.essh blog
with the example from above, instead ofssh -i /path/to/key user@domain
Hostname
: The IP/domain of the serverUser
: User on the remote system you want to connect withIdentityfile
: The path to your private key
Connect
Now we can easily connect with just ssh blog
instead, much simpler. This of course also applies to scp
.