我在 Azure 的私有网络区域设置了一个开发虚拟机。现在我尝试通过 SSH 连接到它,但由于某种原因失败了。我确定我已将正确的公钥上传到 Azure VM,并且用户名也正确。
vagrant@7XZRVZ2:~/.ssh/dev-vm$ ssh -vvvv -i /home/vagrant/.ssh/dev-vm/id_rsa [email protected]
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
它成功达到本地版本字符串...,但 5 或 10 秒后出现了一个kex_exchange_identification: Connection closed by remote host error
我无法理解的错误。我搜索了这个错误,但没有找到解决我的问题的方法。
我检查了 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 设置了 FW 规则,是否可能还需要添加其他端口?
答案1
这确实是公司内网的另一个防火墙。我没有注意到,因为我可以访问服务器。如果您遇到同样的问题,请再次检查防火墙。