Trouble remembering server names? Here’s a tip!

So, if you have a lot of different servers in which you login via ssh and, like me, you find some of their names a little bit hard to remember, you are gonna love this.
If you use ssh often, there should be a config file in your ~/.ssh/ directory. If there isn’t one there, it’s ok, just create it. Let’s suppose that you want to be able to reach the server with name through ssh but you don’t want to have to write each time ssh

Here’s what you should do. You should open the config file and write :

 Host shortCut
      User username

Then, save the file. Now, each time that you write ssh shortCut in the terminal, ssh will automatically run in the background the full command, ssh, and ask you for your password. Of course, you can change shortcut to something related with the server you want to connect and you can add more options and servers below that.

Another thing you can do is enable controlMaster. To do that, open the .ssh/config file again and write at the end :

Host *
ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto

What will that do you ask? Let’s say that you want to login through ssh at a server via two or more different terminals. Normally you have to authenticate each time, so that ssh will be able to set up more than one secure connections to your server. If you enable ControlMaster however, you won’t have to do this more than once for each session. After you authenticate with the server once, ssh will use the existing connection for every new session with that server! Try it out.

There are many more things that you can do with an ssh config file. In this case, the internet is the reference but you can also try man ssh_config.

Let me google that for you.