1. Home
  2. Knowledge Base
  3. Virtual Private Server (VPS)
  4. Change SSH Port (CentOS & Debian)

By default, port 22 is used to establish an SSH connection. This port is automatically configured during the installation of your operating system. 

To reduce the number of brute force attacks, you can configure another port for SSH access. 

Please Note

Before changing the port, make sure that the applications and services installed on the server can be configured without a default port. Otherwise, changing the default port may cause these applications and services to stop working.

To change the SSH port:

  • Log on to the server as an administrator.
  • Open the SSH configuration file sshd_config with the text editor vi:
    vi /etc/ssh/sshd_config
  • Search for the entry Port 22.
  • Replace port 22 with a port between 1024 and 65536.
  • Save the file.
  • Restart the service.
  • Ubuntu
    service ssh restart
    CentOS 7

    systemctl restart sshd
    To establish an SSH connection after this change, enter the following command:
    ssh root@IP_address_of_the_server -p NewPort

Was this article helpful?

Related Articles

Leave a Reply

All right reserved and copyright protected by Leeds Technologies