SSH端口号修改并进行远程访问

1. 修改配置文件sshd_config里端口号

[root@test ~]# vi /etc/ssh/sshd_config
//change
# default value.
 
Port 5000 #将注释打开,并且修改端口号
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

2. 重启sshd服务

[root@test ~]# service sshd restart

3. 打开通过端口5000的访问

解决:

1)关闭防火墙

[root@test ~]# service iptables stop

2)修改iptables的配置文件

[root@test ~]# vi /etc/sysconfig/iptables
#
-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 40339 -j ACCEPT

重启iptables

[root@test ~]# service iptables restart

4. 远程主机访问时

[root@frankie ~]# ssh test -p 5000

猜你喜欢

转载自www.cnblogs.com/cos235817497/p/10364638.html