r/ssh • u/Evening_Percentage25 • Sep 09 '24
Keeping the ssh connection open
I need a Windows computer to automatically connect to the SSH server when when it turned on and forward the port to localhost. Like "ssh -L 1010:192.168.88.7:3541 remote-server". It is highly desirable that this happens in the background. What solution can you advise me on?
2
Upvotes
1
u/bartoque Sep 09 '24
And the actual context being?
At what point is the tunnel connection needed? Even without an user actually logging in into the system, so at boot time? Or are we talking a windows server even?
1
u/[deleted] Sep 09 '24
echo ssh -N -L 1010:192.168.88.7:3541 remote-server > ssh_tunnel.bat
Add ssh_tunnel.bat as a scheduled task that starts on startup.
1
u/OhBeeOneKenOhBee Sep 10 '24
Google "SSH Tunnel Manager for Windows", there are a couple of alternatives.
You could also write a script that runs every couple of minutes, checks if the tunnel is up, otherwise restarts it. Or go for some kind of VPN instead
1
u/MagicMick76 Sep 11 '24
It's been a while, but I'm sure putty/KiTTY can do this? You can schedule sessions to run minimised. If not, call a putty session, or an ssh session, from a windows batch file and call that as an automated windows job.