Connect to your remote server by performing these steps:
1.Run the following command in your terminal:
ssh (username)@(IP address)
Replace the (username) with your account user name, and (IP address) with your VPS IP address. For instance:
ssh [email protected] (use your server IP )
Note: If this is your first time changing the port or even using SSH, you need to confirm whether you’ll continue connecting to a remote device. Type yes to allow the connection.
2.Input your password and click Enter.
Once you’ve established the connection, follow these steps to configure a new port number:
1.Access the SSH daemon (sshd) by executing this command on your text editor. We’ll be using the vi command in this example.
vi /etc/ssh/sshd_config
2.Find the line that says #Port 22 and change it to your desired port. If you’re using vi, you need to press i to enter insert mode. Only then can you delete the old port and change it. After that hit esq to exit insert mode. Type wq to save your changes and quit.
3.Set up your new port number below the old one by removing the hashtag and typing in the new desired number, for instance:
For example : port :1026
4.After changing the port, you need to restart SSH daemon using this command:
service sshd restart
5.Once restart SSHD service try with your new port to access your server.