First, we must edit the SSHD (SSH server daemon) configuration file. Use your favorite text editor.

#vim /etc/ssh/sshd_config

Add the following code to the bottom of the configuration file. To go to bottom of the file just press “shift+g”.

# SSH Port
Port 9752 # the port you want to change

Next, we’ll update the firewall. If you have disabled the firewall, skip this step. My example uses port 9752. For CentOS 6 users, run these commands:

#iptables -I INPUT -p tcp –dport 9752 –syn -j ACCEPT
#service iptables save
#semanage port -a -t ssh_port_t -p tcp 9752

CentOS 7 users, run these commands instead:

#firewall-cmd –add-port 9752/tcp –permanent
#firewall-cmd –add-port 9752/tcp

The configuration changes are now finished. Restart the SSH service (SSHD)…

#service sshd restart

–Done.

WhatsApp chat