How To Change SSH Port In CentOS 7


This article will provide a guide for how to change SSH port in CentOS 7 server. For server administrators, you may want to help secure your CentOS VPS or dedicated servers by changing the port used to access SSH interface.

How to Change SSH Port in CentOS 7 Server

To change SSH port in CentOS 7 server, follow these instructions:

  1. Login to the server via SSH.
  2. Disable SELinux.
  3. Access the SSH configuration using the following command:
    nano /etc/ssh/sshd_config
  4. Locate the line containing "#Port 22":
    edit sshd config file
  5. Uncomment the line and change the port to your desired SSH port number (i.e. Port 7299):
    Change SSH port in CentOS 7
  6. Exit and save the file.
  7. Add the new port number to the firewall rules to allow access:
    sudo firewall-cmd --zone=public --permanent --add-port=7299/tcp --reload
  8. Restart sshd service:
    sudo systemctl restart sshd
  9. Login to SSH using the new port number.

Conclusion

You now know how to change SSH port in CentOS 7 server.

  • ssh, ssh commands, centos 7, centos
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Forcefully Delete an IP Address from SolusVM

If at any point you find you have an orphaned ipaddress, you can delete it by running the...

Do You Offer a Hardware Firewall Solution?

Yes, we have a very limited selection of hardware firewalls available. We appreciate the specific...

View Server PHP Environment with phpinfo.php

The phpinfo() function outputs a huge amount of information about the system you're using, such...

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH....

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH....