If you’re a Linux user and you often log in to remote machines or servers, then this tutorial may save you some time. It’s a tip that user Oshunluvr from kubuntuforums.net showed me a few months ago. I’ve been using it ever since.
It will allow you to log into machines with SSH servers on custom ports, with a specified username, by typing:
ssh firstname.lastname@example.org -p 1234
As I discussed in a previous post, raspberry pi server preparation, there are many bots out there that search for ssh servers and try to brute force their way in. In order to attract less unwanted attention, you may choose to forward a non-standard port on your router to port 22 on your server.
This has the annoying side effect of requiring you to specify the port when you connect with the -p option.
To make things easier, you can edit (or create) a ssh config file:
sudo nano ~/.ssh/config
For each machine you would like to connect to, add the following:
Host yourdomain.com User username Port 1234
Now you can connect by typing
ssh yourdomain.com, without specifying a username and port each time.