Wednesday, November 16, 2016

Change ssh default port in Centos 7

Hi folks,

For the latest Centos7 Operating system ssh port change need below procedures,

take backup of original ssh config file,

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

Then edit config file of ssh to add new port in the line

#Port 22 (uncomment it and change port number from 22 to desired number)

If semanage package not existing run below command,

yum -y install policycoreutils-python

Then add new port number to selinux configuration to allow for ssh,

 semanage port -a -t ssh_port_t -p tcp 'port'

Then restart ssh service ,

service sshd restart

If firewalld is using in the server add new port to firewall,

firewall-cmd --permanent --zone=public --add-port='port'/tcp
firewall-cmd --reload


That's all fellas ....................