How To Change Default SSH Port in Linux, Ubuntu or Centos

  1. How to change the default SSH Port in Linux or Ubuntu which is 22 to increase the security.
  2. Just loginto your SSH server using root.
  3. Then use some editor like nano or vi to edit the sshd configuration file.
  4. Then type nano /etc/ssh/sshd_config
    You can use other editor like vi if nano is not installed but working with vi is a little different.
  5. If nano is not installed you can install is using yum install nano in CentOS.
  6. Now lets save the new port number and exit.
  7. Press Ctrl + X
  8. Type Y for YES.
  9. Don’t change the file name and save it by the default location/name i.e. /etc/ssh/sshd_config. Just press enter.
  10. Once you have saved it just restart the system or the sshd service using the following command.
    service sshd restart
  11. Then see the active port by following command
    service sshd status

You can also see this complete guide on How to Change Default Port of SSH in Linux, Ubuntu or Centos on our official Youtube channel.

Leave a Reply

Your email address will not be published. Required fields are marked *