[Tutor] ssh script
brunson at brunson.com
Wed Jan 23 17:51:42 CET 2008
> Hello, I'm trying to write a script which will allow me to create a reverse
> tunnel from a remote machine using SSH -R
> I know the reverse tunnel script works on it's own run from the shell, but I
> don't want to leave it open always... does anyone have any ideas on how to
> make this work? There seems to be something wrong with the subprocess call
> such that it just hangs on the remote side...
> import os, time, subprocess
> REMOTE_HOME='../' #mounted drive to REMOTE_HOME from LOCAL_MACHINE
> cmd = 'while true; do ssh -R 8022:localhost:22 MyUserName at RemoteHost ; sleep
You probably need to add "-t" to the ssh invocation since you won't have
a controlling terminal.
If that doesn't fix it, then try inserting some debugging output to know
what's going on.
> 60; done'
> while 1:
> while os.path.exists(os.path.join(REMOTE_HOME,'mySecretFile'):
> if proc: os.kill(proc.pid)
> if os.path.exists(os.path.join(REMOTE_HOME,'KillScript'):
More information about the Tutor