I set up an SSH Reverse tunnel using ssh -o StrictHostKeyChecking=no -R 2222:localhost:22 [email protected]. The tunnel connect to the remote server and opens port 2222. I connect into the tunnel with ssh -p 2222 user@tunnelclient and it works fine. I jump into the tunnel and land on the other machine. A few minutes go by an then the remote host closes the connection.

I start a ping to keep the activity going, and still, the remote host (the client that starts the tunnel to the remote server) drops the connection.

Q: How can I stop this from happening?

... snip ...
64 bytes from icmp_seq=70 ttl=64 time=0.080 ms
64 bytes from icmp_seq=71 ttl=64 time=0.079 ms
64 bytes from icmp_seq=72 ttl=64 time=0.076 ms
64 bytes from icmp_seq=73 ttl=64 time=0.080 ms
64 bytes from icmp_seq=74 ttl=64 time=0.080 ms
64 bytes from icmp_seq=75 ttl=64 time=0.080 ms
64 bytes from icmp_seq=76 ttl=64 time=0.080 ms
Connection to localhost closed by remote host.
Connection to localhost closed.
  • This is often caused by an unstable network connection. You could try monitoring with netstat -i at each end. If possible, you could run the ssh server and/or client with the -d option and it should tell you why it is closing the connection. Jun 11, 2020 at 8:19
  • it was the Type= field in the systemd service. Jun 11, 2020 at 12:34

1 Answer 1


Found the problem. I solved it by changing the systemd service Type= from forking to simple see below.

Description="SSH Reverse Tunnel Service"

ExecStart=/bin/ssh -vvv -o StrictHostKeyChecking=no -R 2222: remoteuser@remoteserver


Now it works well and seems to be stable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .