我可以使用一台 PC 连接到远程服务器,但不能使用另一台 PC 连接到远程服务器,
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "*******" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ***** [****] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: SELinux support disabled
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.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.1
ssh_exchange_identification: Connection closed by remote host
我不得不说这是一个新问题,几天前我能够连接,是什么原因导致这种情况?为什么只有一台电脑无法连接?我总是使用相同的登录名。另外,我不知道为什么它会在 /root/.ssh 中查找身份文件,因为我正在以普通用户身份运行命令
谢谢
答案1
看起来您没有正确的公钥文件。尝试将它们从正常工作的计算机复制到不正常工作的计算机。它们应该位于您的主目录中的某个位置。通常为 id_rsa.pub。
如果您检查您的 known_hosts 文件并删除不正常工作的文件,然后通过以下方式重新连接您的主机,也可以解决此问题:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
要找出 known_hosts 文件中哪个文件是您不正常工作的文件,请比较 id_rsa.pub 中的密钥和 known_hosts 文件中的条目。