Centos7 modify SSH port

A, SSH command

View status:

#systemctl status sshd.service
start the service:

#systemctl start sshd.service
restart the service:

#systemctl restart sshd.service
boot from the start:

#systemctl enable sshd.service

Two, SSH modify the port

#vi /etc/ssh/sshd_config

Find #Port 22

Add the following two lines

Port 22 # Add default port 22, resulting in the failure to prevent the setting can not connect

Port xxx #xxx for your new port

Save and exit, and restart the ssh service.

#systemctl restart sshd.service

Third, modify the firewall

Add a new firewall port

# Firewall-cmd --zone = public --add-port = XXX / tcp --permanent // XXX for the new port

Reload firewall configuration

#firewall-cmd --reload

View new port status

#firewall-cmd --zone=public --query-port=XXX/tcp

Four, SELinux configuration

If you modified the port, add a firewall to use the new port can not use the new port link. SELinux configuration issues might be of.

Method 1: Close SELinux

View SElinux state

# / Usr / sbin / sestatus -v ## if SELinux status parameter is enabled is the open state

SELinux status:                 enabled

Close SElinux

#vi /etc/selinux/config

SELINUX=enforcing => SELINUX=disabled

Restart the machine.

#reboot

 Method 2: Add a new port to the SELinux

No, he continued.

V. delete 22 ports

If the normal connection, you can annotate the default port 22.

#vi /etc/ssh/sshd_config

Port 22 Delete this line.

Restart the ssh service.

#systemctl restart sshd.service

Guess you like

Origin www.cnblogs.com/NeigeBolg/p/12601915.html