ssh登录立即退出 闪退问题解决

54,991次阅读
没有评论

在Docker中使用了其它作者的LNMP包,在管理文件时ssh登录总是闪退,经过查询日志,问题在于最后3行

. 2017-11-06 22:20:44.508 Prompt (password, "SSH password", <no instructions>, "密码(&P):")
. 2017-11-06 22:20:44.508 Using stored password.
. 2017-11-06 22:20:44.534 Sent password
. 2017-11-06 22:20:44.593 Access granted  //这里显示登录成功
. 2017-11-06 22:20:44.593 Opening session as main channel
. 2017-11-06 22:20:44.595 Opened main channel
. 2017-11-06 22:20:44.638 Started a shell/command
. 2017-11-06 22:20:44.690 --------------------------------------------------------------------------
. 2017-11-06 22:20:44.691 Using SCP protocol.
. 2017-11-06 22:20:44.694 Doing startup conversation with host.
. 2017-11-06 22:20:44.694 Server sent command exit status 254  //问题出现,闪退!
. 2017-11-06 22:20:44.694 Disconnected: All channels closed

Google找到问题原因,这个是因为,默认配置下,启用了超时断开连接功能。把sshd_config文件中的UsePAM改成no就可以了。

sshd_config文件说明: OpenSSH SSH 服务器守护进程配置文件

位置:/etc/ssh/sshd_config

进入文件系统修改保存重启sshd服务即可,如是在Docker内,请用docker ps列出容器ID,再用docker exec 命令进入容器修改

docker ps   //列出容器,获得CONTAINER ID 
    docker exec -it 622c6e26e948 /bin/bash //使用容器ID(3b6ec4343647)进入容器管理

进入容器后用vi编辑sshd_config文件

vi /etc/ssh/sshd_config

ssh登录立即退出 闪退问题解决

PS:vi简单使用方法 – 进入后按下方向键下翻,注意查找 UsePAM yes 行,光标移动到最后Del删除yes,敲入no,按两次ESC退出编辑模式,输入:wq回车即保存。

重启sshd服务 service sshd restart

正文完
 0
withero
版权声明:本站原创文章,由 withero 2017-11-06发表,共计1141字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码