[paramiko] ssh -r , dynamic set up

John washakie at gmail.com
Sun Jan 27 02:03:32 PST 2008


Hello, I'm trying to write a script which will allow me to initiate
(spawn?) a reverse tunnel from a remote machine (outside a firewall) to an
internal machine using SSH -R

I posted to another list and was pointed in the direction of paramiko. I've
read the tutorials, but cannot seem to figure out exactly how I can do
this... I'm hoping someone can look at what I'm trying to do below and
provide an example...

#!/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

-- 
Note, 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...  furthermore it seems to be a
rather 'brute force' method. It seems paramiko might provide a more elegant
solution! Does anyone have any ideas on how to make this work?


Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Five 1.4.1,
Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat
4.1.1-51)],
PIL 1.1.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lag.net/pipermail/paramiko/attachments/20080127/31ac329b/attachment.html 


More information about the paramiko mailing list