How to Change SSH Access Port in Linux

By default servers will use port 22 for SSH access but it’s highly recommended to change the SSH port to something more random to prevent malicious users from attempting to access your server.

  • Step 1. Log in to your server via a terminal with an account that has root/sudo privileges.

  • Step 2. Using a text editor (in this case nano) edit the /etc/ssh/sshd_config file.
sudo nano /etc/ssh/sshd_config
  • Step 3. Find the line “#Port 22” and remove the “#” and then change the number to your desired port.

  • Step 4. Save the changes and reload the SSHD service using the following command.
sudo service sshd restart

Ensure you have tested the new port in a new SSH window before exiting your current session.

Please rate this article to help us improve our Knowledge Base.

0 0