ssh登录异常

情景描述:
开发同事报告使用某普通用户test无法远程登陆一台,报错“shell request failed on channel 0”。
解决过程
mark

  • 判断内存空间是否充足
  • 查看用户是否存在(排除误操作删除用户的可能)
  • 查看公钥文件(authorized_kys),ssh配置文件(.ssh/config)以及自定义的公钥文件(id_rsa_gitlab_deploy)
  • 使用w查看当前终端在线的用户
  • "lsof /dev/pts/*"查看当前服务器中文件描述符被哪些进程占用
  • 使用sudo su test尝试登录服务器,报错:“su: failed to execute /bin/bash: 资源暂时不可用”==>大概定位为FD资源不足
  • 执行lsof命令,列出当前系统打开文件的工具,同时会显示进程的状态,此时发现有好多close_wait进程
  • 进一步确认,为代码问题,告知相关开发人员
  • kill掉进程(非线上重要进程,kill前和开发沟通好),开发人员修复后自己启动。

2018/02/26
今天,在做jenkins的时候ssh到另一台Linux机器失败!报错如下

[root@Dasoncheng ~]# ssh [email protected]
[email protected]'s password:
##我已经把公钥放在服务端了,还是让我输入密码;我就重启了一下服务端 结果:
[root@Dasoncheng ~]# ssh [email protected]
ssh_exchange_identification: read: Connection reset by peer
##等待了一会 结果报上面的错误。我就百度了

解决方法:

[root@Dasoncheng2 var]# cd /var/
[root@Dasoncheng2 var]# chmod -R 755 *
继续百度,又跑到一个歪果仁的网站上,在一个不起眼论坛的一个不起眼的帖子中一个不起眼的跟帖中,一个哥们很低调的说了句“I know this quesiton is old ,
but I wanted to share some findings I had,Check if /var/empty/sshd on the server has appropriate ownership and permissions.
We had a chef script that was modifile toupdate some directory peimisions,but indavertently updated the diectory below the 
intended target,chaning ownership of /var to an applicaton user/group and changing the permissons to 755."
去/var下看了看,果然权限很大,都是777,cd 到 empty 目录,果然有ssh这个文件夹,在cd进去,啥也没有了。于是直接执行两条命令: 
cd /var 
chmod -R 755 * 
然后就再次尝试了远程连接了下,竟然ok了。

mark
原文链接:http://blog.csdn.net/x6_9x/article/details/49983607
一个非常棒的ssh登录失败 排错经验:https://www.cnblogs.com/starof/p/4709805.html


猜你喜欢

转载自my.oschina.net/u/3651233/blog/1625029