Debian/Centos system, modify the default SSH port

888u

Last update at :2024-06-30,Edit by888u

Debian/Centos two systems are the same, under SSH: Take changing the port to 7438 as an example.

1. Add the changed port to the firewall a. Add firewall exceptions under Centos 7

firewall-cmd --permanent --add-port=7438/tcp

Restart the firewall

firewall-cmd --reload

b. Add firewall exceptions under Centos 6

vi /etc/sysconfig/iptables

Find the existing ssh line and change 22 to the new SSH port number

Restart the firewall before

service iptables save service iptables restart

c. Add firewall exceptions under Debian

vi /etc/sysconfig/iptables

Add

iptables -A INPUT -p tcp --dport 7438 -j ACCEPT

Save and restart the firewall

/etc/init.d/iptables restart

2. Modify the /etc/ssh/sshd_config file.

vi /etc/ssh/sshd_config

Find the code below

#Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress ::

Remove the # in front of the #Port 22 line and change 22 to another port

Revised example:

Port 7438 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress ::

3. Restart the SSH service

service sshd restart

Recommended site search: free website domain name application, domain name query, Hong Kong cloud server, domain name registration website, mainland China registration-free space, free virtual host application rental server website IP address query free virtual host, Guangzhou host rental,

Debian/Centos system, modify the default SSH port

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码