请阅读整个问题,底部有一些非常重要的信息!
我正在尝试使用反向 SSH 隧道将所有前往 VPS 端口 25565(IP 地址 XXXX)的流量转发到我家用 PC 的端口 25565(IP 地址 YYYY)。以下是我正在使用的命令:
ssh -f -v -N -T -R25565:localhost:25565 X.X.X.X (on my home PC)
ssh -v -p 25565 kevin@localhost (on my VPS)
但是,第二个命令成功运行并首先连接约 20 秒,但随后退出并显示kex_exchange_identification: Connection closed by remote host
。我的 VPS 和家用电脑的文件GatewayPorts=yes
都有。sshd_config
尝试连接到我的 Minecraft 服务器会导致超时,即使在第二个命令运行的大约 20 秒内也是如此。第一个命令运行良好。
对于我的 VPS,运行sudo tail -n300 /var/log/auth.log | grep "ssh"
显示以下内容:
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on 0.0.0.0 port 22.
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on :: port 22.
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on 0.0.0.0 port 80.
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on :: port 80.
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on 0.0.0.0 port 443.
Apr 17 18:04:56 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2189]: Server listening on :: port 443.
Apr 17 18:07:00 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2191]: Accepted publickey for kevin from 147.147.74.12 port 34680 ssh2: RSA SHA256:ZK8Guh7WfKkthpCpwtH1vg5izkyWGe24OusFPbCaqz8
Apr 17 18:08:09 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2208]: error: kex_exchange_identification: Connection closed by remote host
Apr 17 18:08:09 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2209]: Invalid user from 45.227.254.10 port 1356
Apr 17 18:08:09 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2209]: Connection closed by invalid user 45.227.254.10 port 1356 [preauth]
Apr 17 18:11:09 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2217]: Accepted publickey for kevin from 147.147.74.12 port 34812 ssh2: RSA SHA256:ZK8Guh7WfKkthpCpwtH1vg5izkyWGe24OusFPbCaqz8
Apr 17 18:11:29 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2221]: Unable to negotiate with 194.146.224.65 port 34273: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 [preauth]
Apr 17 18:12:31 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2233]: Accepted publickey for kevin from 147.147.74.12 port 34832 ssh2: RSA SHA256:ZK8Guh7WfKkthpCpwtH1vg5izkyWGe24OusFPbCaqz8
Apr 17 18:13:12 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2237]: Received disconnect from 221.181.185.220 port 58408:11: [preauth]
Apr 17 18:13:12 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2237]: Disconnected from authenticating user root 221.181.185.220 port 58408 [preauth]
Apr 17 18:13:47 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2242]: Accepted publickey for kevin from 147.147.74.12 port 34854 ssh2: RSA SHA256:ZK8Guh7WfKkthpCpwtH1vg5izkyWGe24OusFPbCaqz8
Apr 17 18:17:23 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2251]: error: kex_exchange_identification: banner line contains invalid characters
Apr 17 18:17:23 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2252]: error: kex_exchange_identification: banner line contains invalid characters
Apr 17 18:17:23 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2252]: error: send_error: write: Connection reset by peer
Apr 17 18:17:25 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2253]: error: kex_exchange_identification: client sent invalid protocol identifier "GET / HTTP/1.1"
Apr 17 18:17:25 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2254]: error: kex_exchange_identification: client sent invalid protocol identifier "GET / HTTP/1.1"
Apr 17 18:17:26 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2255]: Connection reset by authenticating user root 66.228.33.98 port 50894 [preauth]
Apr 17 18:17:26 ubuntu-s-1vcpu-1gb-lon1-01 sshd[2257]: Connection reset by authenticating user root 69.164.222.108 port 55782 [preauth]
Apr 17 18:20:26 ubuntu-s-1vcpu-1gb-lon1-01 sudo: kevin : TTY=pts/0 ; PWD=/etc/ssh ; USER=root ; COMMAND=/usr/bin/tail -n300 /var/log/auth.log
Apr 17 18:22:28 ubuntu-s-1vcpu-1gb-lon1-01 sudo: kevin : TTY=pts/0 ; PWD=/etc/ssh ; USER=root ; COMMAND=/usr/sbin/ufw allow 25565
Apr 17 18:24:02 ubuntu-s-1vcpu-1gb-lon1-01 sudo: kevin : TTY=pts/0 ; PWD=/etc/ssh ; USER=root ; COMMAND=/usr/bin/tail -n300 /var/log/auth.log
我的问题是:
- 我究竟做错了什么? (如果有什么)
- 我该如何纠正我的错误?
最终,我最大的问题是如何让反向 SSH 隧道正常工作,以便所有到 XXXX:25565 的 Minecraft 流量都转发到实际服务器运行的 YYYY:25565。
值得注意的是,XXXX 正在运行 OpenVPN,并充当客户端 YYYY 的 OpenVPN 服务器