I have a server, and I have a desktop that is behind an awkward network. In order to access my desktop remotely, I have it maintain a reverse SSH connection to my server, and then I can SSH to my server and SSH to the desktop via whatever reverse-SSH port it is using.
Specifically, my desktop is running a wee Bash script like this:
#!/bin/bash while true; do ssh -X -R 19123:localhost:22 http://www.example.pro/ sleep 1000 done
Then, on the server, the desktop is accessible using a command like the following:
ssh localhost -p 19123
This seems to work fine. The connection is maintained and re-established reliably, and I can run commands and the like on the server from the desktop, verifying that the connection is indeed alive.
However, after a while, like a few days, the desktop becomes inaccessible from the server. On the desktop, the connection is alive, but on the server the following error message gets returned:
ssh: connect to host localhost port 19123: Connection refused
Can anyone guess at what might be happening? And, more importantly, can anyone suggest how this can be prevented from happening, given that the server cannot be restarted regularly and the like?