<div>Hello, I&#39;m trying to write a script which will allow me to&nbsp;initiate (spawn?)&nbsp;a reverse tunnel from a remote machine (outside a firewall)&nbsp;to an internal machine using SSH -R</div>
<div>&nbsp;</div>
<div>I posted to another list and was pointed in the direction of paramiko. I&#39;ve read the tutorials, but cannot seem to figure out exactly how I can do this... I&#39;m hoping someone can look at what I&#39;m trying to do below and provide an example...<br>
<br>#!/usr/bin/python<br><br>import os, time, subprocess<br>REMOTE_HOME=&#39;../&#39; &nbsp;#mounted drive to REMOTE_HOME from LOCAL_MACHINE <br><br>cmd = &#39;while true; do ssh -R 8022:localhost:22 MyUserName@RemoteHost ; sleep<br>
60; done&#39;<br>while 1:<br>&nbsp; &nbsp; &nbsp; &nbsp;while os.path.exists(os.path.join(REMOTE_HOME,&#39;mySecretFile&#39;):<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proc= subprocess.call(cmd,shell=&#39;True&#39;)<br><br>&nbsp; &nbsp; &nbsp; &nbsp;if proc: os.kill(proc.pid)<br><br>
&nbsp; &nbsp; &nbsp; &nbsp;if os.path.exists(os.path.join(REMOTE_HOME,&#39;KillScript&#39;):<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break<br clear="all"><br>-- <br></div>
<div>Note, I know the reverse tunnel script works on it&#39;s own run from the shell, but I don&#39;t want to leave it open always...&nbsp; furthermore it seems to be a rather &#39;brute force&#39; method. It seems paramiko might provide a more elegant solution! Does anyone have any ideas on how to&nbsp;make this work?<br>
</div>
<div>&nbsp;</div>
<div>&nbsp;</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>