This article walks you through setting up your SSH config file
Your SSH config file (commonly located at ~/.ssh/config) contains some common settings to save you time entering details when connecting over SSH, and can also automate many things like tunneling, proxy jumps, automatically using specific usernames and SSH keys, etc.
This post will walk you through some of the basics, but there's a lot of more powerful things you can do that we will leave out.
One of the simplest things you can do is give one or more aliases to a server you connect to often to not have to type it out all the time. Lets say you often connect to big.server.url.com with this command:
$ ssh [email protected]
Instead of typing the full thing out, we can simply update our ~/.ssh/config file to contain:
# Multiple aliases for the server
Host bigserver big
# Full URL/IP of the server
HostName big.server.url.com
Now, we can just use bigserver or big when connecting:
$ ssh my_user@big # Much easier to type!
By default, if no username is provided to the SSH command, it defaults to using the same one as your current system. In case these are not the same, you usually have to manually enter the correct username every time. Going along with the example from above, assuming the username on the server is my_user we would need to run:
$ ssh my_user@big
We can add the default username to use for a server as follows:
Host bigserver big
HostName big.server.url.com
# If no username provided, set `my_user` as default
User my_user
Now, we can just run:
$ ssh big # Short and sweet!