当前位置: 移动技术网 > 科技>操作系统>Linux > Linux ssh突然连接不了的案例浅析

Linux ssh突然连接不了的案例浅析

2019年07月25日  | 移动技术网科技  | 我要评论

公司的linux服务器都是通过一台jumpserver跳转的。个人使用jumpserver(开源跳板机系统)时,有时候由于需要上传、下载文件很不方便。而由于配置关系,一般情况无法使用securecrt直接通过ssh连接到服务器。所以个人设置了/etc/ssh/sshd_config。允许我的电脑(电脑名+域名)直接使用ssh访问linux主机。

 

但是今天使用securecrt连接时提示密码验证错误,使用jumpserver跳板机当然可以连接。连接上去后检查分析原因,具体过程如下所示:

 

 

先看看是否有修改过密码,如下所示,上一次修改密码已经很久了。最近没有修改过密码,而且我使用使用securecrt保存密码的,不是手工输入的。所以虽然提示密码验证失败,但是实际情况应该是其它原因引起(不是因为密码不正确的原因)

 

#chage -l oracle
last password change                                    : feb 24, 2019
password expires                                        : never
password inactive                                       : never
account expires                                         : never
minimum number of days between password change          : 0
maximum number of days between password change          : 99999
number of days of warning before password expires       : 7

 

检查/var/log/secure日志,发现原来我的电脑(ip地址等信息做了脱敏处理)不允许通过ssh连接这台服务器

 

jul 24 11:41:25 xxxxx sshd[30836]: user oracle from 192.168.xxx.xxx not allowed because not listed in allowusers
jul 24 11:41:25 xxxxx sshd[30839]: input_userauth_request: invalid user oracle
jul 24 11:41:25 xxxxx sshd[30836]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.xxx.xxx  user=oracle
jul 24 11:41:27 xxxxx sshd[30836]: failed password for invalid user oracle from 192.168.xxx.xxx port 63278 ssh2
jul 24 11:41:30 xxxxx sshd[30839]: received disconnect from 192.168.xxx.xxx: 13: the user canceled authentication.

 

 

但是我在/etc/ssh/sshd_config配置文件里面,我已经设置了允许我的个人电脑(此笔记本有加入公司的域)访问这台linux服务器。

 

allowusers *@xxxx.xxx.xxxx.com

 

使用ping xxx.xxx.xxx.com测试时,发现电脑名无法被解析,终于确定是因为dns服务器异常,导致无法解析我的机器名,从而引起ssh连接主机时出现这个错误。其实最开始的时候,/etc/ssh/sshd_config是使用ip地址配置的。但是由于笔记本有时候获取的ip地址是变化的。从而在/etc/ssh/sshd_config里面设置使用机器名。结果dns异常的时候,就出了这么一档子事情。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网