SSH,建立连接,但卡住了

xhg*_*xhg 7 ssh vpn

我可以在我的房子里服务器,但我没有通过一些VPN或公共wifi(不是全部)ssh.当我输入时ssh -v user@server.domain,我得到了这个:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug1: Connecting to server.domain [server.ip.address] port 22.
debug1: Connection established.
debug1: identity file /Users/Hung/.ssh/id_rsa type 1
debug1: identity file /Users/Hung/.ssh/id_rsa-cert type -1
debug1: identity file /Users/Hung/.ssh/id_dsa type -1
debug1: identity file /Users/Hung/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
Run Code Online (Sandbox Code Playgroud)

然后,只要它可以没有响应.有人可以帮忙吗?以下是正常的:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug1: Connecting to server.domain [server.ip.address] port 22.
debug1: Connection established.
debug1: identity file /Users/Hung/.ssh/id_rsa type 1
debug1: identity file /Users/Hung/.ssh/id_rsa-cert type -1
debug1: identity file /Users/Hung/.ssh/id_dsa type -1
debug1: identity file /Users/Hung/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 15:6e:7a:db:35:7c:6a:ba:3e:c0:c1:24:4d:5a:be:a8
debug1: Host 'server.domain' is known and matches the RSA host key.
debug1: Found key in /Users/Hung/.ssh/known_hosts:13
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/Hung/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to server.domain ([server.ip.address]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_CTYPE = UTF-8
Run Code Online (Sandbox Code Playgroud)

Ben*_*pel 5

这可能是 VPN 链路或 WiFi 链路上的 MTU 存在问题。您可以尝试降低 VPN 上的 MTU 大小(假设tap0是您的 VPN 设备,在 Linux 上):

ifconfig tap0 mtu 1200
Run Code Online (Sandbox Code Playgroud)

Windows和Mac还有其他设置MTU的机制,我没有尝试过:

最大传输单元 (MTU) 是您可以通过链路发送的数据包的最大大小。如果您到服务器的链接的 MTU 为 1500,但您将 VPN 配置为以 MTU 1484 运行,则来自服务器的大数据包必须分成两部分以适合 1484 大小的数据包。一些廉价的路由器/防火墙无法正确处理此问题,并且仅转发第一个数据包。因此,一旦您尝试发送必须分段的大数据,只有第一个片段能够通过。因此,您的客户端将等待第二个片段重新组装整个数据包,直到超时,这将阻止您的连接。当服务器向您发送一个大数据包时,可能会发生这种情况,例如在您登录时出现一个大的“欢迎屏幕”。

来源: http: //www.snailbook.com/faq/mtu-mismatch.auto.html

  • 我也遇到了这个问题,但不是在 VPN 上。我将两端的 MTU 设置为 100,问题仍然存在。我可以用 nc 打开套接字。SSH 只是不想工作。有任何想法吗? (2认同)