ssh 提示Connection closed by * 的解决方案

  使用ssh方式连接linux系统时,发现一直上报这个错误:

Connection closed by 192.168.3.71 port 22 刚开始还以为是端口被防火墙禁止了呢,通过关闭和查看,并没有发现

什么错误,这就要详细的分析了。到底是哪儿出的问题呢?

  根据思路来,先看log:从log可以看出,出错的原因很明显,就是加密文件权限有问题了,接下来就去查看和改动文件权限。

Mar 24 09:35:50 sshd[3306]: error: Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open.
Mar 24 09:35:50 sshd[3306]: error: It is required that your private key files are NOT accessible by others.
Mar 24 09:35:50 sshd[3306]: error: This private key will be ignored.
Mar 24 09:35:50 sshd[3306]: error: key_load_private: bad permissions
Mar 24 09:35:50 sshd[3306]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Mar 24 09:35:50 sshd[3306]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Mar 24 09:35:50 sshd[3306]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Mar 24 09:35:50 sshd[3306]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Mar 24 09:35:50 sshd[3306]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
Mar 24 09:35:50 sshd[3306]: error: It is required that your private key files are NOT accessible by others.
Mar 24 09:35:50 sshd[3306]: error: This private key will be ignored.
Mar 24 09:35:50 , sshd[3306]: error: key_load_private: bad permissions
Mar 24 09:35:50 , sshd[3306]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Mar 24 09:35:50 , sshd[3306]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Mar 24 09:35:50 , sshd[3306]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Mar 24 09:35:50 , sshd[3306]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Mar 24 09:35:50 , sshd[3306]: error: Permissions 0777 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
Mar 24 09:35:50 , sshd[3306]: error: It is required that your private key files are NOT accessible by others.
Mar 24 09:35:50 , sshd[3306]: error: This private key will be ignored.
Mar 24 09:35:50 , sshd[3306]: error: key_load_private: bad permissions
Mar 24 09:35:50 , sshd[3306]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Mar 24 09:35:50 , sshd[3306]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Mar 24 09:35:50 , sshd[3306]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @

  在/etc/ssh目录下查看,的确是文件权限有问题,不知道什么原因,文件权限被改成了777,按照别的系统的文件权限,修改成下面的即可:

-rw-r--r--   1 root root 300261 1月  18 22:15 moduli
-rw-r--r--   1 root root   1756 1月  18 22:15 ssh_config
-rw-r--r--   1 root root   2542 3月   7 10:12 sshd_config
-rw-------   1 root root    672 3月   7 10:12 ssh_host_dsa_key
-rw-r--r--   1 root root    615 3月   7 10:12 ssh_host_dsa_key.pub
-rw-------   1 root root    227 3月   7 10:12 ssh_host_ecdsa_key
-rw-r--r--   1 root root    187 3月   7 10:12 ssh_host_ecdsa_key.pub
-rw-------   1 root root    419 3月   7 10:12 ssh_host_ed25519_key
-rw-r--r--   1 root root    107 3月   7 10:12 ssh_host_ed25519_key.pub
-rw-------   1 root root   1675 3月   7 10:12 ssh_host_rsa_key
-rw-r--r--   1 root root    407 3月   7 10:12 ssh_host_rsa_key.pub
-rw-r--r--   1 root root    338 3月   7 10:12 ssh_import_id

 

转载于:https://www.cnblogs.com/dylancao/p/8637312.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值