【问题标题】:OpenVPN: connection problems / ssh_exchange_identification: read: Connection reset by peer [closed]OpenVPN:连接问题/ ssh_exchange_identification:读取:对等方重置连接[关闭]
【发布时间】:2016-06-21 16:24:07
【问题描述】:

我在使用 OpenVPN 和 SSH(以及其他服务)时遇到问题:

我可以在没有任何错误消息的情况下连接到 VPN。 如果我想通过 SSH 连接到 VPN 内的计算机,我会收到错误消息:“ssh_exchange_identification: read: Connection reset by peer”。

这个问题发生在哪台机器上每天都不同,连接到连接。

$ ssh root@storage -vvv
OpenSSH_6.9p1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to storage [192.168.1.5] port 22.
debug1: Connection established.
debug1: identity file /home/ewald/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ewald/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
ssh_exchange_identification: read: Connection reset by peer

如果我可以连接到 VPN 内的另一台机器,我可以通过 SSH 连接到我的目标。 此外,我尝试在远程路由器上为端口 22 配置端口转发,并经常通过此转发从我的客户端连接,它始终有效,所以我认为问题不在于 SSH 服务器或客户端配置。

所以我在 OpenVPN 配置中尝试了许多设置(不同的 link-mtus、tcp 而不是 udp、禁用 lzo、...),将其安装在另一台机器上(默认 OpenVPN 服务器在 Ubuntu 12.04 VM 中。我试过了也将其安装在裸机上)并且没有任何改变。

自从第一次出现问题以来,甚至更改了 ISP(从 DSL 到 Fiber)。

其他客户端机器也存在问题:使用粘度的 macbook(tunnelblick 也不起作用),几个 linux 机器:fedora、ubuntu、...

有时我也没有收到来自 HTTP 服务器的答复(即使我可以使用 SSH 连接到它) HTTP服务器本身可以从内部网络和我的SSH隧道(使用它作为SOCKS代理)访问,所以问题一定是OpenVPN连接。

谁能帮帮我?如果连接本身有问题,我该如何检查?

TCP 转储:

$ sudo tcpdump -i tun0 dst port 22
15:56:17.689847 IP myclient.60920 > storage.ssh: Flags [S], seq 729708226, win 29200, options [mss 1460,sackOK,TS val 3108117687 ecr 0,nop,wscale 7], length 0
15:56:17.717556 IP myclient.60920 > storage.ssh: Flags [.], ack 2044707578, win 229, options [nop,nop,TS val 3108117714 ecr 1518717699], length 0
15:56:17.717949 IP myclient.60920 > storage.ssh: Flags [P.], seq 0:21, ack 1, win 229, options [nop,nop,TS val 3108117715 ecr 1518717699], length 21
15:56:17.945811 IP myclient.60920 > storage.ssh: Flags [P.], seq 0:21, ack 1, win 229, options [nop,nop,TS val 3108117943 ecr 1518717699], length 21

【问题讨论】:

    标签: http ubuntu networking ssh openvpn


    【解决方案1】:

    可能缺少 POSTROUTING 规则,能否将这条命令的结果粘贴(在 openvpn 服务器上)?

    iptables -L -t nat
    

    如果没有规则你可以试试:

    iptables -t nat -A POSTROUTING -j MASQUERADE
    

    还要验证 ipv4 转发(在 openvpn 服务器上):

    cat /proc/sys/net/ipv4/ip_forward
    

    如果结果为0,则必须在'/etc/sysctl.conf'中添加这一行:

    net.ipv4.ip_forward = 1
    

    如果有帮助请告诉我

    【讨论】:

    • 确实没有 POSTROUTING 规则。现在它似乎工作了。谢谢你。奇怪的是,例如 PING 可以工作,有时我可以连接到其他主机。
    • 我很高兴听到它现在可以正常工作,请您验证我的回答吗? (它可以帮助处于相同情况的其他人)。谢谢你:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    • 2015-05-15
    • 1970-01-01
    • 2018-11-01
    相关资源
    最近更新 更多