Read from socket failed: Connection reset by peer

通常,在linux中使用ssh的时候,如果出现这个错误,建议首先去查看log。

ubuntu的ssh的log记录在/var/log/auth.log

log错误会类似于如下:

Dec 22 09:43:31 x079-liongao sshd[14883]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:31 x079-liongao sshd[14883]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Dec 22 09:43:31 x079-liongao sshd[14883]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:31 x079-liongao sshd[14883]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
Dec 22 09:43:31 x079-liongao sshd[14883]: error: It is recommended that your private key files are NOT accessible by others.
Dec 22 09:43:31 x079-liongao sshd[14883]: error: This private key will be ignored.
Dec 22 09:43:31 x079-liongao sshd[14883]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
Dec 22 09:43:31 x079-liongao sshd[14883]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Dec 22 09:43:35 x079-liongao sudo:  liongao : TTY=pts/3 ; PWD=/home/liongao ; USER=root ; COMMAND=/usr/bin/ssh localhost
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:35 x079-liongao sshd[14892]: error: Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: It is recommended that your private key files are NOT accessible by others.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: This private key will be ignored.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
Dec 22 09:43:35 x079-liongao sshd[14892]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dec 22 09:43:35 x079-liongao sshd[14892]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: It is recommended that your private key files are NOT accessible by others.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: This private key will be ignored.
Dec 22 09:43:35 x079-liongao sshd[14892]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
Dec 22 09:43:35 x079-liongao sshd[14892]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key


很明显是权限的问题。只要将/etc/ssh目录下的所有文件都修正为正确的权限即可。如果你不知道修改为多少,可以去看看你默认安装ssh成功后的目录权限。最好还是卸载了ssh再重新安装一次。

你可能感兴趣的:(socket,File,command,ssh,ubuntu,permissions)