Linux ssh突然連接不了的案例淺析


公司的Linux服務器都是通過一台JumpServer跳轉的。個人使用Jumpserver(開源跳板機系統)時,有時候由於需要上傳、下載文件很不方便。而由於配置關系,一般情況無法使用SecureCRT直接通過ssh連接到服務器。所以個人設置了/etc/ssh/sshd_config。允許我的電腦(電腦名+域名)直接使用ssh訪問Linux主機。

 

但是今天使用SecureCRT連接時提示密碼驗證錯誤,使用JumpServer跳板機當然可以連接。連接上去后檢查分析原因,具體過程如下所示:

 

image

 

先看看是否有修改過密碼,如下所示,上一次修改密碼已經很久了。最近沒有修改過密碼,而且我使用使用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異常的時候,就出了這么一檔子事情。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM