
Linux下修改端口号只需要更改相应服务的配置文件即可,下面以修改linux 的SSH服务的默认端口号22为例(把22修改我2501):
1、修改/etc/ssh/sshd_config配置文件
[root@localhost ssh]# more sshd_config# $OpenBSD: sshd_config,v 1.69 2004/05/23 23:59:53 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22 //先把22注释掉
port 2501 //添加一个新的端口
#Protocol 2,1
2、重启ssh服务让修改的端口号生效
[root@localhost ~]# service sshd restartStopping sshd:[ OK ]
Starting sshd:[ OK ]
vi /etc/ssh/sshd_config,找到Port 22,然后将端口22改为你想要的端口号,重启SSH服务:/etc/init.d/sshd restart即可,然后测试ssh连接:ssh localhost -p 你的端口号,连接成功。\x0d\x0a如果你希望保险起见,不至于因为一个端口连接不了(比如受到攻击)而不能使用ssh连接,那么你可以使用多个ssh连接端口,还是在配置文件/etc/ssh/sshd_config中修改,运行vi /etc/ssh/sshd_config,找到Port 端口号地方,然后在下面添加一行:Port 23,这样就又增加了一个新的连接端口,重启SSH服务,\x0d\x0a测试ssh localhost -p 23,连接成功。\x0d\x0a另外需要注意的是,如果本机测试没有问题,但还是不能使用第三房工具从外部SSH链接的话,需要关闭防火墙\x0d\x0a,重新启动一下SSHD。 这样就可以。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)