<div>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</div>
<div> </div>
<div>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...<br>
<br>#!/usr/bin/python<br><br>import os, time, subprocess<br>REMOTE_HOME='../' #mounted drive to REMOTE_HOME from LOCAL_MACHINE <br><br>cmd = 'while true; do ssh -R 8022:localhost:22 MyUserName@RemoteHost ; sleep<br>
60; done'<br>while 1:<br> while os.path.exists(os.path.join(REMOTE_HOME,'mySecretFile'):<br> proc= subprocess.call(cmd,shell='True')<br><br> if proc: os.kill(proc.pid)<br><br>
if os.path.exists(os.path.join(REMOTE_HOME,'KillScript'):<br> break<br clear="all"><br>-- <br></div>
<div>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?<br>
</div>
<div> </div>
<div> </div>
<div>Configuration<br>``````````````````````````<br>Plone 2.5.3-final,<br>CMF-1.6.4,<br>Zope (Zope 2.9.7-final, python 2.4.4, linux2),<br>Five 1.4.1,<br>Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat 4.1.1-51)],<br>
PIL 1.1.6 </div>