![连接到 ssh 主机的本地计算机返回错误?](https://linux22.com/image/157195/%E8%BF%9E%E6%8E%A5%E5%88%B0%20ssh%20%E4%B8%BB%E6%9C%BA%E7%9A%84%E6%9C%AC%E5%9C%B0%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%EF%BC%9F.png)
我试图弄清楚如何克服这个错误:我读了一些类似的帖子,但我找不到什么是直接的,我希望得到一些关于我能做什么的建议
macminngh:MDATA sondosayyash$ ssh -Y -v [email protected]
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to goblin.sharcnet.ca [199.241.162.29] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host
答案1
这不是远程主机上的错误,而是客户端的问题。
debug1: key_load_public: No such file or directory
debug1: identity file /Users/sondosayyash/.ssh/id_rsa type -1
第一行是关键;它找不到文件/Users/sondosayyash/.ssh/id_rsa
.
/Users/
至少在类 Unix 机器上,默认情况下不存在这样的目录。通常,这将是/home/sondosayyash/.ssh/id_rsa
.
您可以通过导航到.ssh
主目录中的目录来验证这一点。
# Navigate to /home/user/.ssh
cd ~/.ssh
# Validate the absolute path of your .ssh directory
pwd
# Display the contents of the directory
ls
如果该目录中没有id_rsa
密钥文件,则需要创建密钥对。该网站上已经有创建密钥对的答案: