远程主机关闭连接

远程主机关闭连接

我正在尝试使用通过 cPanel 生成并存储在本地计算机上的私钥连接到服务器,但收到“远程主机已关闭连接”的消息。有什么想法吗?

XXXXX-computer-2:~ XXXX$ ssh -v -i /path/to/private/key [email protected]
OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to xxx.com XX.XX.XX.XX] port 22.
debug1: Connection established.
debug1: identity file /path/to/private/key type -1
ssh_exchange_identification: Connection closed by remote host

答案1

其中一种可能性是您在服务器上已经建立了太多 ssh(死连接),这可能是由于从 ssh 不适当的注销造成的。

尝试ps -ef | grep ssh在该服务器上。查看是否已建立大量 ssh。如果除了 ssh 之外找不到其他方法进入服务器。一种糟糕的方法是重启服务器。它应该可以正常工作 :p

答案2

要检查的其他问题是您的 /etc/hosts.allow /etc/hosts.deny 文件是否拒绝来自您的 IP 的 ssh 连接。

使用更详细的连接命令将为您提供更详细和更准确的消息原因。

我已经在我的局域网中尝试过了,下面是由于这个原因而被拒绝的连接的示例日志:

%ssh-v 192.168.0.13
OpenSSH_4.3p2,OpenSSL 0.9.8e-fips-rhel5 2008 年 7 月 1 日
debug1:读取配置数据 /etc/ssh/ssh_config
debug1:应用选项 *
debug1:连接到192.168.0.13 [192.168.0.13]端口22。
debug1:连接已建立。
debug1:身份文件/home/user/.ssh/identity type -1
debug1:身份文件/home/user/.ssh/id_rsa 类型-1
debug1:身份文件/home/user/.ssh/id_dsa 类型 -1
debug1: 加载3个键
ssh_exchange_identification:远程主机关闭连接

答案3

当 SSH 受到 DOS 攻击时,我遇到了此问题。如果尝试的连接过多,某些连接可能会因此错误而失败。

答案4

您正在使用协议版本 1 的标识文件。某些 ssh 服务器默认不接受协议 1 版本。

相关内容