为什么我无法通过 ssh 进入我的 ubuntu 服务器?(ssh_exchange_identification 错误)

为什么我无法通过 ssh 进入我的 ubuntu 服务器?(ssh_exchange_identification 错误)

我正在尝试通过 ssh 进入我的 ubuntu 服务器(我之前已经做过很多次了)但出现了错误:

ssh_exchange_identification:远程主机关闭连接

ssh -vvv 显示以下内容:

jimsmith:etc jimsmith$ ssh -vvv galleryserver
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/jimsmith/.ssh/config
debug1: Applying options for galleryserver
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /Users/richardelliot/.ssh/galleryserverkey.pem.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /Users/richardelliot/.ssh/galleryserverkey.pem type -1
debug1: identity file /Users/richardelliot/.ssh/galleryserverkey.pem-cert type -1
ssh_exchange_identification: Connection closed by remote host

有人可以帮忙吗?

- 更新 - -

我刚刚发现服务器已升级。所以基本上它是一台新机器,但它使用相同的密钥和 IP 地址

答案1

似乎你没有使用正确的 SSH 私钥,正如

debug3: Not a RSA1 key file /Users/richardelliot/.ssh/galleryserverkey.pem.

SSH 密钥通常不是 .pem 文件 - 通常是为 x509 证书保留的。检查 ~/.ssh 中的 ssh 密钥;通常您有类似“id_dsa”(私钥)和“id_dsa.pub”(公钥)的内容。如果使用 RSA,则这些文件是 id_rsa 和 id_rsa.pub。确保该主机的 SSH 配置 ~/.ssh/config 指向正确的 SSH 密钥。

如果这些文件不存在,您可以使用以下命令生成它们

ssh-keygen -t dsa

然后给你的私钥一个密码,并使用类似钥匙链管理您的密钥。然后您将复制本地工作站公钥 ~/.ssh/id_dsa.pub 并将其合并到 ~/.ssh/authorized_keys 中偏僻的服务器 - 如果需要,创建该文件。确保权限并且服务器配置正确。

答案2

好的,我明白问题出在哪里了。

一个名为“拒绝主机”的模块阻止了我的 IP 连接。

我设法从另一个 IP 地址连接,然后将我的 IP 地址添加到 /etc/hosts.allow 文件中。

相关内容