Linux下sshd启动失败问题解决一例
今天一台Redhat Linux AS4出了问题,ssh无法连接。
检查日志(/var/log/secure 文件)发现如下错误提示:sshd[3862]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
sshd[3862]: fatal: Cannot bind any address.
sshd[3879]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
sshd[3879]: fatal: Cannot bind any address.
提示显示端口22被占用,绑定失败。
在网上可以找到类似的案例,一般的解释是ipv4与ipv6启动冲突。
在 /etc/ssh/sshd_config 文件中存在以下设置:
ListenAddress 0.0.0.0
ListenAddress ::
其中0.0.0.0是ipv4的地址,::是IPv6的表示,如果IPv4地址绑定22端口,则后续绑定会失败,通常的建议是如果不使用IPv6,则可以注释后面一行。
可是我们的问题还没有这么简单,因为缺省的,以上两行配置已经被注释。
检查系统开放的端口及服务:
[root@cmjp1 ~]# nmap -sT -O localhostStarting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2006-11-15 14:00 CST
Nmap run completed -- 1 IP address (1 host up) scanned in 2.199 seconds
Insufficient responses for TCP sequencing (3), OS detection may be less accurate
Interesting ports on cmjp1.hurray.com.cn (127.0.0.1):
(The 1655 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
631/tcp open ipp
873/tcp open rsync
Device type: general purpose
Running: Linux 2.4.X|2.5.X|2.6.X
OS details: Linux 2.4.0 - 2.5.20, Gentoo 1.2 linux (Kernel 2.4.19-gentoo-rc5), Linux 2.4.20,
Linux 2.4.20 - 2.4.22 w/grsecurity.org patch, Linux 2.5.25 - 2.6.3 or Gentoo 1.2
Linux 2.4.19 rc1-rc7)
Uptime 0.089 days (since Wed Nov 15 11:52:15 2006)
可以发现22端口已经启动,但是客户端是无法通过ssh协议连接的。
同时在系统中观察到另外的一个现象是,即使通过ssh作为客户端访问远程主机也不能连接:[root@cmjp ~]# ssh root@172.16.33.130
The authenticity of host '172.16.33.130 (172.16.33.130)' can't be established.
RSA key fingerprint is 20:7c:8e:15:19:f7:e7:0c:5d:ce:6f:1c:c6:de:f2:0b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.33.130' (RSA) to the list of known hosts.
root@172.16.33.130's password:
Segmentation fault
Segmentation fault多半说明应用程序存在问题,导致指针访问错误,通过重新安装sshd程序,最终解决了该问题。
-The End-
- 2021-11-15 循序渐进 openGauss :初始化参数的设置、查询和修改
- 2021-11-15 openGauss 高级特性介绍
- 2017-11-15 千丝万缕:Oracle扩展统计信息虚拟列引发OGG 1161错误
- 2012-11-15 ACOUG 2012 Oracle技术嘉年华活动结束
- 2011-11-15 清除统计信息的内部操作-DELETE_COLUMN_STATS
- 2011-11-15 希腊游记 - 雅典 众神的府邸
- 2010-11-15 attempt to access beyond end of device很危险
- 2009-11-15 HP-UX Oracle Ioctl ASYNC_CONFIG error=1
- 2008-11-15 完成 ITPUB 高校巡讲 华北电力、北京理工站
- 2005-11-15 支持公益宣传,请更换您的msn头像
- 2005-11-15 iSCSI节点名称定义及其他
- 2005-11-15 NetAPP iSCSI性能测试
- 2004-11-15 使用热备份进行分时恢复
用 netstat -tnlp 看是否是sshd 开的22端口
大部分服务器报这个纯粹配置问题,关闭IPV6的监听就可以。但不能连接远程服务器应该应用程序损坏有关系
#cat /etc/ssh/sshd_config
......
#Port 22
#Protocol 2,1
#ListenAddress 0.0.0.0
#ListenAddress ::
......
#service sshd restart
#cat /var/log/secure
......
Dec 3 11:10:19 localhost sshd[25953]: Server listening on :: port 22.
Dec 3 11:10:19 localhost sshd[25953]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
......
修改配置后:
#cat /etc/ssh/sshd_config
......
Port 22
#Protocol 2,1
ListenAddress 0.0.0.0
#ListenAddress ::
......
#service sshd restart
#cat /var/log/secure
......
Dec 3 11:10:43 localhost sshd[25968]: Server listening on 0.0.0.0 port 22.
......