Linux Modify SSH Port 22
The code is as follows |
Copy Code |
Vi/etc/ssh/ssh_config Vi/etc/ssh/sshd_config |
Then change to port 8888
As Root service sshd restart (Redhat AS3)
Using putty, Port 8888
Linux under the default SSH port is 22, for security reasons, now modify the SSH port is 1433, modify the method as follows:
The code is as follows |
Copy Code |
/usr/sbin/sshd-p 1433 |
First modify the configuration file
The code is as follows |
Copy Code |
Vi/etc/ssh/sshd_config |
Find #port 221, here is the identity default use 22 port, modified to the following:
The code is as follows |
Copy Code |
Port 22 Port 50000 |
And then save the exit
Perform/etc/init.d/sshd restart
This way the SSH port will work concurrently with 22 and 50000.
Modify iptables configuration file: Vi/etc/sysconfig/iptables Add the following:
The code is as follows |
Copy Code |
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 50000-j ACCEPT |
Restart the Iptalbes service:
The code is as follows |
Copy Code |
Service Iptables Restart |
Now, use the SSH tool to connect to port 50000 to test for success.
If the connection succeeds, edit the Sshd_config settings again and delete the Port22 inside.
Set to two ports, the test is successful and then close a port, is the way in the process of modifying the Conf,
In the event of a drop, disconnection, misoperation and other unknown circumstances, but also through another port connection up debugging
In order to avoid the connection must send someone to the computer room, causing problems more complicated trouble.
Of course, you can also directly turn off the firewall (not recommended):
Effective after reboot
The code is as follows |
Copy Code |
Open: Chkconfig iptables on Close: Chkconfig iptables off |
Immediate effect, reboot disabled
The code is as follows |
Copy Code |
Open: Service iptables start OFF: Service iptables stop |