Have to leave terminals open on both machines for ssh tunnel
My problem is I'm trying to automate the my ssh reverse tunnels.
Currently I have to do this... ROAMING NOTEBOOK -> ROUTER -> INTERNET -> ROUTER -> HOME-MACHINE First I run this on the notebook: Code:
#!/bin/bash Then I have to run this command on my home machine to open the reverse tunnel: Code:
ssh 127.0.0.1 -p 25000 -l username -X I'd like to connect to the roaming notebook with this reverse tunnel from my home machine, so I need to run the tunnel script on the notebook at start up. I can successfully achieve all of this ... its just I need to automate the notebook side. The notebook OS is Mint7. So I have tried running the notebook script with the startup preferences, but it neither opens a terminal, or even the ssh tunnel. I have public keys, so password prompts aren't a problem. My bash is novice at best, below average... and my experience is mostly with openrc and baselayout in Gentoo. Also if my home machine isn't on, I'd like the script on the notebook to exit, if host isn't available. Need some suggestions and maybe some sample code. I'm familiar with loops, and case statements... etc Just need idea's where to start on the notebook side. EDIT: I dont always have to keep my terminal open on my home machine ... Its with the notebook. Tunnel only stays open if I leave the terminal open, with the above script. |
I do tunnelling too. I made myself a script that runs in cron and is configured like this:
Code:
* * * * * /path/to/my/script mymachine.***.** 22 25000 > /path/to/log 2>&1 Code:
#!/bin/ksh |
Quote:
And here's the notebooks startup script: Code:
#!/bin/sh And here is the netstat from my server once the notebook shutdowns or restarts: Code:
# netstat -anp | grep :9874 |
On the server there should be a process that ties the port. You need to identify the process (lsof command might be of assistance), and track when its parent becomes process id 1 you know it is now an orphan and should be killed. Killing that process would then release the port.
|
All times are GMT -5. The time now is 04:15 AM. |