ssh登陆异常

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

  • 判断内存空间是否充足
  • 查看用户是否存在(排除误操做删除用户的可能)
  • 查看公钥文件(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机器失败!报错以下git

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

解决方法:shell

[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.htmlbash

相关文章
相关标签/搜索