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.

Changing the SSH port is considered a good security practice to circumvent the brute force attempts on port 22.

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 أعضاء وجدوا هذه المقالة مفيدة
هل كانت المقالة مفيدة ؟

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 Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...