Xshell ssh 连接后一段时间就掉线 Connection closed by foreign host
Posted 李学文
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Xshell ssh 连接后一段时间就掉线 Connection closed by foreign host相关的知识,希望对你有一定的参考价值。
问题现象:
发现本机sshd服务开启但是其他机器不能登陆
Xshell ssh 连接后一段时间就掉线 Connection closed by foreign host
查看sshd服务
[[email protected] ~]# systemctl status sshd.service ● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2017-06-18 03:55:51 PDT; 21min ago Docs: man:sshd(8) man:sshd_config(5) Process: 3789 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 3791 (sshd) CGroup: /system.slice/sshd.service └─3791 /usr/sbin/sshd Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: bad permissions: ignore key: /etc/ssh/ssh_host_ecdsa_key Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: Permissions 0604 for ‘/etc/ssh/ssh_host_ed25519_key‘ are too open. Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: It is required that your private key files are NOT accessible by others. Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: This private key will be ignored. Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: bad permissions: ignore key: /etc/ssh/ssh_host_ed25519_key Jun 18 04:17:07 localhost.localdomain sshd[4304]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
解决方法:可以很容易看出来这是因为ssh服务的配置文件的访问权限有问题,配置文件路径为/etc/ssh,将这些文件的权限修改为如下即可:
[[email protected] ssh]# ls -al total 288 drwxr-xr-x. 2 root root 225 Jun 18 03:55 . drwxr-xr-x. 138 root root 8192 Jun 18 03:54 .. -rw-r--r--. 1 root root 242153 Nov 11 2016 moduli -rw-r--r--. 1 root root 2208 Nov 11 2016 ssh_config -rw-r--r-- 1 root root 4362 Jun 18 03:55 sshd_config -rw-------. 1 root ssh_keys 227 May 31 18:43 ssh_host_ecdsa_key -rw-r--r--. 1 root root 162 May 31 18:43 ssh_host_ecdsa_key.pub -rw-------. 1 root ssh_keys 387 May 31 18:43 ssh_host_ed25519_key -rw-r--r--. 1 root root 82 May 31 18:43 ssh_host_ed25519_key.pub -rw-------. 1 root ssh_keys 1679 May 31 18:43 ssh_host_rsa_key -rw-r--r--. 1 root root 382 May 31 18:43 ssh_host_rsa_key.pub [[email protected] ssh]#
以上是关于Xshell ssh 连接后一段时间就掉线 Connection closed by foreign host的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7.1 Xshell 经常掉线 Connection closed by foreign host
xshell用ssh连接aix时,命令输错按backspace时,命令实际被删除但在xshell上还显示。