我在 Digital Ocean 上有一个 droplet。它的凭据与我的一个朋友共享。我们过去通过 ssh 连接到它:
ssh root@IP_Address
现在由于注意力不集中,我们在服务器上运行以下命令时犯了一个错误:
sudo chmod -R 777 /
由于该服务器不再通过任何方式(SSH/FTP/...)连接,并出现以下错误:
ssh_exchange_identification: read: Connection reset by peer
这是输出ssh root@IP_Address -vv
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "IP_Address" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to IP_Address [IP_Address] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/talha/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 ssh_exchange_identification: read: Connection reset by peer
请尽快帮助我,因为我没有托管项目和数据库的最新备份。
先感谢您!
答案1
作为最低要求,请通过 DO 控制台登录 root 用户(请参阅这里了解说明)并执行
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
(换句话说,将 的访问权限设置为和/root/.ssh
。rwx------
如果其他用户可以访问该文件,SSH 将不会信任该文件。/root/.ssh/authorized_keys
rw-------
您可能还必须设置对 /etc/ssh 中的文件的正确访问权限:
-rw-r--r-- 1 root root 300261 Aug 11 2016 moduli
-rw-r--r-- 1 root root 1830 Sep 19 2016 ssh_config
-rw------- 1 root root 672 Oct 2 2016 ssh_host_dsa_key
-rw-r--r-- 1 root root 605 Oct 2 2016 ssh_host_dsa_key.pub
-rw------- 1 root root 227 Oct 2 2016 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 177 Oct 2 2016 ssh_host_ecdsa_key.pub
-rw------- 1 root root 411 Oct 2 2016 ssh_host_ed25519_key
-rw-r--r-- 1 root root 97 Oct 2 2016 ssh_host_ed25519_key.pub
-rw------- 1 root root 1675 Oct 2 2016 ssh_host_rsa_key
-rw-r--r-- 1 root root 397 Oct 2 2016 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root 338 Sep 19 2016 ssh_import_id
-rw-r--r-- 1 root root 2598 Sep 19 2016 sshd_config