Centos7 modify SSH port number

  

Note! The Centos version here is 7

step1 Modify /etc/ssh/sshd_config vi /etc/ssh/sshd_config #Port 22 //This line is removed ##Port 20000 //Add this line below

step2 Modify SELinux Use the following command to view the current ssh ports allowed by SElinux: semanage port -l |  Grep ssh

Add 20000 ports to SELinux semanage port -a -t ssh_port_t -p tcp 20000

Then confirm if you add it to semanage port -l |  Grep ssh

If successful, it will output ssh_port_t tcp 20000, 22

step3 restart ssh systemctl restart sshd.service

Copyright © Windows knowledge All Rights Reserved