How to change the SSH port for a Linux server

Secure Shell (SSH) allows HostPapa VPS users to log in and manage their server using a command-line application, such as Terminal on Mac OS and Linux, or a third-party application like PuTTY on Windows. SSH communications typically operate over port 22, but if you wish to tighten security, you could change the SSH port to an alternative. Use the following steps to change the SSH port for a Linux server.

Port 22

Log in to your VPS server using SSH, using Terminal or an alternative SSH command-line app. You should log in with the root administrator.

SSH login

Once logged in, run the following command:

vi /etc/ssh/sshd_config

SSH Configuration file

The SSH configuration file will open. Locate the following line:

# Port 22

Port line

Type i to enter the vi text editor’s Insert mode. Delete the “#” and change the port number to an alternative. Press Escape to return to vi’s Command mode.

Type “: x” (without the space) to save the file and quit the vi text editor.

Now run the following command to restart the SSH service on your server with the new port number.

service sshd restart

If you need help with your HostPapa account, please open a support ticket from your dashboard.

Related Articles

Get online with our affordable web hosting

Get online with our affordable web hosting

Learn more now
HostPapa Mustache