我最近将运行Dropbear的服务器上的ssh监听端口从22更改为一个随机端口,以防止有人通过暴力破解方式使系统日志被淹没。
一切正常,我可以使用Termux(一个可安装软件包的Android终端模拟器)从WAN侧连接到服务器。
但是当我尝试使用我的 MacBook ssh 到此服务器时(与我的手机处于同一网络下,并且之前在dropbear监听22端口时能够ssh到服务器),连接立即中断,ssh 输出以下信息:
kex_exchange_identification: write: Broken pipe
详细输出并没有展示任何有用的信息(而且还很突兀地被切断了,我可以补充一下)。
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/my_username/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to remote.yhaoquan.top port 2123.
debug1: Connection established.
debug1: identity file /Users/my_username/.ssh/id_rsa type 0
debug1: identity file /Users/my_username/.ssh/id_rsa-cert type -1
debug1: identity file /Users/my_username/.ssh/id_dsa type -1
debug1: identity file /Users/my_username/.ssh/id_dsa-cert type -1
debug1: identity file /Users/my_username/.ssh/id_ecdsa type -1
debug1: identity file /Users/my_username/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/my_username/.ssh/id_ed25519 type -1
debug1: identity file /Users/my_username/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/my_username/.ssh/id_xmss type -1
debug1: identity file /Users/my_username/.ssh/id_xmss-cert type -1
kex_exchange_identification: write: Broken pipe
通过 Telnet 连接到 2123 端口,表明我已经成功连接到服务器:
>telnet {hostname} 2123
Trying {host IP address}...
Connected to {hostname}
Escape character is '^]'.
SSH-2.0-dropbear
|
��]J044��d����curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,kexguess2@matt.ucc.asn.aursa-sha2-256,ssh-rsa3chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctr3chacha20-poly1305@openssh.com,aes128-ctr,aes256-ctrhmac-sha1,hmac-sha2-256hmac-sha1,hmac-sha2-256nonenoneM�'�Rf
当我把服务器端口改回22时,一切正常。
有人知道问题可能在哪里或者我应该如何诊断问题吗?谢谢
编辑1: 对于那些遇到相同问题的人,一个临时解决方案是使用OpenSSH。最简单的方法(使其成为一个即插即用的解决方案)是使用Homebrew:
brew install openssh
这个命令将会把你使用的ssh客户端从/usr/bin/ssh
改成一个别名,指向/usr/local/bin/ssh
,该别名指向了使用brew刚刚安装的OpenSSH
,这样症状似乎不会再出现。
然而,这并没有解决这篇文章所涉及的问题。我仍在寻找解决方案。
/usr/bin/ssh
) 来进行 SSH 连接。我还无法证明这一点,但是今天早上邮件和命令行 ssh 都开始出现故障。因此,我仍在寻找一个“真正”的解决方案,因为我认为这是修复邮件程序所必需的。 - Eric Moyer