With cygwin, how do you restart an ssh reverse tunnel without a forwarding problem "Warning: remote port forwarding failed" message occurring?
I have this command ssh -R 50500:127.0.0.1:5900 user@myip
and it logs me into my ssh server.
The idea is I have a computer I want to view, and a computer that is the viewer. And the computer myip, is the intermediary, a hosted VPS.
So the viewed runs the command viewed$ ssh -R 50500:127.0.0.1:5900 user@myip<ENTER>
And the viewer runs the command viewer$ ssh -L 1234:127.0.0.1:50500 user@myip<ENTER>
And then from the viewer computer, I connect VNC viewer to 127.0.0.1:1234
And it all runs well.
Until something happens and VNC won't connect. I have driven away the viewed computer so I can't see the screen, but I take a guess what a possible cause might be. The internet connection at the viewed machine is poor, there's no landline, so I have a router with a mobile SIM card in there. And I have a feeling that maybe the connection breaks from time to time.
So what I tried was this
$ while true; do ssh -R 50500:127.0.0.1:5900 user@myip; done
If I try it, it works, then I go home, and it might still work. But eventually, it doesn't work.. so it's possible that line helped a bit, but I still face a similar issue of VNC connecting for a while, and then not connecting.
So I drive up to the location of the viewed computer, and I look at the viewed computer. And I see some messages like this
user@vps:~# client_loop: send disconnect: Connection reset by peer
Warning: remote port forwarding failed for listen port 50500
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-113-generic x86_64)
...
*** System restart required ***
Last Login...
The word "loop", in "client_loop: send disconnect: Connection reset by peer" is no mystery. The Tight VNC Viewer is doing 127.0.0.1:1234 to ultimately connect to the TightVNC server, and that's fine.
But now I have an idea why VNC won't connect. It won't work because the command on the viewed computer needs to run without that "warning" error / the cause of that "warning" error!!
When the VNC connection doesn't go through, it's because the forwarding isn't working on the "viewed" side. That's a serious problem!
I'm wondering if maybe it's because the connection is flaky, and doesn't fully disconnect when the connection breaks momentarily.
What can I do to deal with the cause of that "warning" error and connect?
I'm not sure if it's an SSH -L that is failing or an SSH -R, or both. Though I think it's probably an SSH -R that is failing 'cos that message about the error in forwarding, comes up on(in the cygwin window /console of), the viewed computer.