zoukankan      html  css  js  c++  java
  • SSH error ( Read from socket failed: Connection reset by peer ) and it's solution

    ssh cann't connected ,event in localhost

    [root@localhost ssh]# ssh 127.0.0.1
    Read from socket failed: Connection reset by peer

    try the following refer to internet ,but failed (the reference OS is UBUNTU, while mine is fedora )

    [root@localhost ~]#ssh-keygen -t dsa  -f  /etc/ssh/ssh_host_dsa_key
    [root@localhost ~]#ssh-keygen -t rsa  -f  /etc/ssh/ssh_host_rsa_key
    [root@localhost ~]#/etc/init.d/ssh restart
    [root@localhost ~]# /etc/init.d/sshd restart
    停止 sshd:                                                [确定]
    正在启动 sshd:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open.
    It is recommended that your private key files are NOT accessible by others.
    This private key will be ignored.
    bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
    Could not load host key: /etc/ssh/ssh_host_rsa_key
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
    It is recommended that your private key files are NOT accessible by others.
    This private key will be ignored.
    bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
    Could not load host key: /etc/ssh/ssh_host_dsa_key
     
    check the log

    [root@localhost ssh]# vi /var/log/messages
    ......
    Jul  4 16:09:57 localhost sshd[21078]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jul  4 16:09:57 localhost sshd[21078]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    Jul  4 16:09:57 localhost sshd[21078]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jul  4 16:09:57 localhost sshd[21078]: error: Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open.
    Jul  4 16:09:57 localhost sshd[21078]: error: It is recommended that your private key files are NOT accessible by others.
    Jul  4 16:09:57 localhost sshd[21078]: error: This private key will be ignored.
    Jul  4 16:09:57 localhost sshd[21078]: error: bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
    Jul  4 16:09:57 localhost sshd[21078]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
    Jul  4 16:09:57 localhost sshd[21078]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jul  4 16:09:57 localhost sshd[21078]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    Jul  4 16:09:57 localhost sshd[21078]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jul  4 16:09:57 localhost sshd[21078]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
    Jul  4 16:09:57 localhost sshd[21078]: error: It is recommended that your private key files are NOT accessible by others.
    Jul  4 16:09:57 localhost sshd[21078]: error: This private key will be ignored.
    Jul  4 16:09:57 localhost sshd[21078]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
    Jul  4 16:09:57 localhost sshd[21078]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
          
    noticing the permissions info , I check the following files in /etc/ssh/

    [root@localhost ssh]# ls -l
    总用量 156
    -rwxrwxrwx. 1 root root 125811 10月  6 2010 moduli
    -rwxrwxrwx. 1 root root   2104 10月  6 2010 ssh_config
    -rwxrwxrwx. 1 root root   3767 10月  6 2010 sshd_config
    -rwxrwxrwx. 1 root root    668  7月  4 15:53 ssh_host_dsa_key
    -rwxrwxrwx. 1 root root    616  7月  4 15:53 ssh_host_dsa_key.pub
    -rwxrwxrwx. 1 root root    965  6月 14 2011 ssh_host_key
    -rwxrwxrwx. 1 root root    630  6月 14 2011 ssh_host_key.pub
    -rwxrwxrwx. 1 root root   1679  7月  4 15:54 ssh_host_rsa_key
    -rwxrwxrwx. 1 root root    408  7月  4 15:54 ssh_host_rsa_key.pub


    [root@localhost ssh]# chmod 600 ssh_host_rsa_key
    [root@localhost ssh]# chmod 600 ssh_host_dsa_key
    [root@localhost ssh]# ls -l
    总用量 156
    -rwxrwxrwx. 1 root root 125811 10月  6 2010 moduli
    -rwxrwxrwx. 1 root root   2104 10月  6 2010 ssh_config
    -rwxrwxrwx. 1 root root   3767 10月  6 2010 sshd_config
    -rw-------. 1 root root    668  7月  4 15:53 ssh_host_dsa_key
    -rwxrwxrwx. 1 root root    616  7月  4 15:53 ssh_host_dsa_key.pub
    -rwxrwxrwx. 1 root root    965  6月 14 2011 ssh_host_key
    -rwxrwxrwx. 1 root root    630  6月 14 2011 ssh_host_key.pub
    -rw-------. 1 root root   1679  7月  4 15:54 ssh_host_rsa_key
    -rwxrwxrwx. 1 root root    408  7月  4 15:54 ssh_host_rsa_key.pub


    retry, it works.

    [root@localhost ssh]# ssh 127.0.0.1
    The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
    RSA key fingerprint is cf:b5:24:67:9c:a9:e9:ab:89:2c:3d:54:5c:13:ed:17.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
    root@127.0.0.1's password:
    Last login: Thu Mar  8 09:31:31 2012 from 192.168.4.139
  • 相关阅读:
    The while statement
    App server 与 Web server之间的区别
    Keyboard input
    Recursion
    Conditionals
    TurtleWorld Exercises
    Python TurtleWorld configuration and simple test
    Why functions
    The python programing language
    性能测试3 方法
  • 原文地址:https://www.cnblogs.com/no7dw/p/2577183.html
Copyright © 2011-2022 走看看