连接到 ssh 主机的本地计算机返回错误?

连接到 ssh 主机的本地计算机返回错误?

我试图弄清楚如何克服这个错误:我读了一些类似的帖子,但我找不到什么是直接的,我希望得到一些关于我能做什么的建议

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密钥文件,则需要创建密钥对。该网站上已经有创建密钥对的答案:

相关内容