栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

关于SSHD的端口维护(改变及增加侦听端口)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

关于SSHD的端口维护(改变及增加侦听端口)

常见的有两种维护需求

1. 改变SSHD的侦听端口

vim /etc/ssh/sshd_config

Port 2222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

效果

[root@server ~]# systemctl restart sshd
[root@server ~]# netstat -ntpl | grep sshd
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      1620/sshd            
tcp6       0      0 :::2222                 :::*                    LISTEN      1620/sshd
2. 增加和改变SSHD的侦听端口

vim /etc/ssh/sshd_config

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

效果

[root@server ~]# systemctl restart sshd
[root@server ~]# netstat -ntpl | grep sshd
tcp        0      0 0.0.0.0:2201            0.0.0.0:*               LISTEN      1666/sshd           
tcp        0      0 0.0.0.0:2202            0.0.0.0:*               LISTEN      1666/sshd
原来已经建立的ssh连接不会断开

在完成systemctl restart sshd重启后,配置文件sshd_config中原来配置的老端口如果已经建立了连接,那么该连接不会立即断开。

[root@server ~]# netstat -ntpa | grep sshd
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      1620/sshd           
tcp        0     36 192.168.74.141:22       192.168.74.1:8602       ESTABLISHED 1571/sshd: root@pts 
tcp6       0      0 :::2222                 :::*                    LISTEN      1620/sshd     

修改配置文件sshd_config将Port改为2222,但修改前的Port 22已经建立了连接,则该连接在重启sshd后会依然保持连接。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/309294.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号