Centos remote SSH port 22 is changed to another port by default
Modify the default SSH port:
1. The file controlling the SSH access port is/etc/ssh/sshd_config.
Therefore, edit the SSH configuration file sshd_config:
# Vi/etc/ssh/sshd_config
2. Find the Port = 22 field and remove the comment above it:
13# Port 22 // remove the annotator #
14 # AddressFamily any
15 # ListenAddress 0.0.0.0
16 # ListenAddress ::
3. Add the same line under this line and change the port number to the one you want to modify:
13 Port 22
14Port 2022 // Add a new row and add the modified Port number
15 # AddressFamily any
16 # ListenAddress 0.0.0.0
17 # ListenAddress ::
4. After saving the modification, restart the SSH service:
#/Etc/init. d/sshd restart // or
# Service sshd restart
5. If no access is available, disable the Firewall:
#/Etc/init. d/iptablesstop // or
# Service iptables stop
Alternatively, add a filter rule to allow access to the newly added port 2022:
# Vi/etc/sysconfig/iptables
Add a policy to allow port 2022:
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 2022-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
6. In this way, you can remotely access the linux host through 2022.