2

Do read the entire question, there is some very important information at the bottom!

I am trying to use a reverse SSH tunnel to forward all traffic that is going to port 25565 of my VPS (with IP address X.X.X.X) to port 25565 of my home PC (with IP address Y.Y.Y.Y). Here are the commands I am using:

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)

However, the 2nd command runs successfully and connects for about ~20 seconds at first, but then exits with kex_exchange_identification: Connection closed by remote host. I have GatewayPorts=yes in the sshd_config files for both my VPS and my home PC. Attempting to connect to my Minecraft server results in a timeout even in the ~20 seconds where the 2nd command is working. The 1st command runs fine.

For my VPS, running sudo tail -n300 /var/log/auth.log | grep "ssh" reveals this:

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

My questions are:

  1. What am I doing wrong? (if anything)
  2. How can I fix my errors?

Ultimately my largest question is how to get the reverse SSH tunnel working so all Minecraft traffic to X.X.X.X:25565 is forwarded to Y.Y.Y.Y:25565 where the actual server is running.

It may be worth noting that X.X.X.X is running OpenVPN and is acting as the OpenVPN server for client Y.Y.Y.Y.

1
  • From the posted log entries, it does not look SSH or the tunnel itself is the problem. Rather, it looks like there's a connectivity issues between them that the tunnel cannot stay connected long enough to complete the SSL handshake. Check your routing tables and IP addresses (I've seen cases where another device on the local network keeps trying to use the same IP as my machine because it thinks it still has the DHCP lease for it.)
    – C. M.
    Commented Apr 21, 2021 at 11:41

0

You must log in to answer this question.

Browse other questions tagged .