zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    LA 3882
    Codeforces 161D
    spoj PARTIT
    uva 10496 Collecting Beepers
    uva 10130 SuperSale
    spoj 3885
    NWERC 2012 Problem I Idol
    NWERC 2012 Problem E Edge Case
    【USACO 1.3.2】修理牛棚
    【USACO 1.3.1】混合牛奶
  • 原文地址:https://www.cnblogs.com/dylancao/p/8637312.html
Copyright © 2011-2022 走看看