ssh_exchange_identification:远程主机关闭连接

ssh_exchange_identification:远程主机关闭连接

第一的:

$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

连接到 SSH 服务器时出现以下消息:

$ ssh -vvv localhost
OpenSSH_5.3p1, OpenSSL 0.9.8m 25 Feb 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/charlie/.ssh/identity type -1
debug1: identity file /home/charlie/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /home/charlie/.ssh/id_dsa.
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
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/charlie/.ssh/id_dsa type 2
ssh_exchange_identification: Connection closed by remote host

我的 /etc/hosts.allow 如下:

sshd: ALLOW

/etc/hosts.deny如下:

ALL: ALL: DENY

我已将 /etc/ssh/sshd_conf 更改为如下形式:

ListenAddress 0.0.0.0
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key


RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

PasswordAuthentication no

答案1

.ssh仔细检查目录和文件的权限.ssh/authorized_keys。它们分别是chmod 700600

答案2

我相当确定

sshd: ALLOW

对于 hosts.allow 来说,语法无效。您可能指的是 ALL,而不是 ALLOW。

答案3

sshd如果您的服务无法运行,您会收到“ssh_exchange_identification:远程主机关闭连接” !

如果您有权访问服务器,请检查该sshd服务是否已运行:

  ps aux | grep ssh

并检查它是否正在监听端口 22:

 netstat -plant | grep :22

更多详细信息请点击此处

答案4

我遇到了类似的问题并通过添加解决了

sshd: ALL

到 /etc/hosts.allow

相关内容