You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure私有网络VM SSH连接失败:kex_exchange_identification错误排查求助

Azure私有网络VM SSH连接失败:kex_exchange_identification错误排查求助

大家好,我在Azure的私有网络里部署了一台开发虚拟机,最近尝试通过SSH连接它时一直失败,折腾了好久都没找到原因,来向各位大佬求助!

我已经确认过两个关键信息:一是上传到Azure VM的公钥是正确的,二是连接用的用户名也没问题。另外,我已经在内部网络的防火墙里配置了允许22端口通行的规则,但连接还是失败。

我执行的SSH命令如下:

ssh -vvvv -i /home/vagrant/.ssh/dev-vm/id_rsa azureuser@10.242.14.6

完整的debug输出日志是这样的:

OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files

debug1: /etc/ssh/ssh_config line 21: Applying options for *

debug2: resolve_canonicalize: hostname 10.242.14.6 is address

debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/vagrant/.ssh/known_hosts'

debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/vagrant/.ssh/known_hosts2'

debug2: ssh_connect_direct

debug1: Connecting to 10.242.14.6 [10.242.14.6] port 22.

debug1: Connection established.

debug1: identity file /home/vagrant/.ssh/dev-vm/id_rsa type 0

debug1: identity file /home/vagrant/.ssh/dev-vm/id_rsa-cert type -1

debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Debian-5+deb11u1

kex_exchange_identification: Connection closed by remote host

Connection closed by 10.242.14.6 port 22

可以看到连接已经建立,但输出完Local version string之后会卡住5-10秒,然后就抛出kex_exchange_identification: Connection closed by remote host这个错误。我搜过这个错误的相关解决方案,但都没适配我的场景。

另外,我还查看了Azure VM上/var/log/auth.log中的sshd日志,当客户端发起连接时,日志里只记录了这一行:

Mar 20 09:28:32 azureuser sshd[15871]: Connection from 10.236.122.24 port 31852 on 10.242.14.6 port 22 rdomain ""

现在我有点摸不着头绪,想问下各位:除了22端口,是不是还有其他端口需要在防火墙中开放?或者还有什么其他的排查方向可以尝试吗?

备注:内容来源于stack exchange,提问作者NFoerster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 10:32:48