[Tutor] ssh script

jay titleistfour at gmail.com
Wed Jan 23 16:15:00 CET 2008


Have you looked into Paramiko?

http://www.lag.net/paramiko/

Its a port of the ssh2 protocol for python.  It might be easier to do this
using that that subprocess calls.  Paramiko is quite nice, I use it a lot at
work.  Just a suggestion....

J

On Jan 23, 2008 3:42 AM, washakie <washakie at gmail.com> wrote:

>
> 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...
>
> #!/usr/bin/python
>
> 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
> 60; done'
> while 1:
>        while os.path.exists(os.path.join(REMOTE_HOME,'mySecretFile'):
>                proc=subprocess.call(cmd,shell='True')
>
>        if proc: os.kill(proc.pid)
>
>        if os.path.exists(os.path.join(REMOTE_HOME,'KillScript'):
>                break
>
> --
> View this message in context:
> http://www.nabble.com/ssh-script-tp15038129p15038129.html
> Sent from the Python - tutor mailing list archive at Nabble.com.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080123/fe670ac3/attachment-0001.htm 


More information about the Tutor mailing list