<br>Has anyone successfully used Python on Windows with SSH connections to Cisco devices? I&#39;m referring to using a Python module (Paramiko, pyssh though not actively developed, Twisted.conch, etc.) and not shelling out via Pexpect (doesn&#39;t work on Windows) or Plink. I need to connect to hundreds of Cisco routers/switches so that I can run numerous commands to gather data. Here is a snippet of my Telnet commands that I need working via SSH:
<br><br><div style="margin-left: 40px;">self.tn.write(&quot;wr\n&quot;)<br>(index, match, read) = self.tn.expect([&quot;OK&quot;], 15)<br>if not match:<br>&nbsp;&nbsp;&nbsp; self.tn.write(&quot;yes\n&quot;)<br>time.sleep(random.uniform(0,2))
<br>self.tn.write(&quot;copy tf runn\n&quot;)<br>self.tn.read_until(&quot;host []?&quot;, 7)<br>time.sleep(random.uniform(0,2))<br>self.tn.write(&quot;192.168.136.51\n&quot;)<br>self.tn.read_until(&quot;filename []?&quot;, 7)
<br>time.sleep(random.uniform(0,2))<br>self.tn.write(self.filename +&quot;\n&quot;)<br>time.sleep(random.uniform(0,2))<br>self.tn.read_until(&quot;[running-config]?&quot;, 7)<br>time.sleep(random.uniform(0,2))<br>self.tn.write
(&quot;\n&quot;)<br></div><br><br>I&#39;ve been able to get the following to work, but the TCP connection closes after each command:<br><br><div style="margin-left: 40px;">import paramiko<br><br>client = paramiko.SSHClient
()<br><br># ignore host keys for the test<br>client.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())<br><br>client.connect(&#39;host####&#39;, 22, &#39;user####&#39;, &#39;passw####&#39;)<br>(stdin, stdout, stderr) = 
client.exec_command(&#39;sh ver | i IOS&#39;)<br>print stdout.read()<br></div><br><br>I&#39;ve read that I can use a dummy channel (not sure the difference between a channel and a TCP connection) to keep the connection active. I&#39;ve read the docs and I&#39;ve searched the net, but I can&#39;t seem to find a good example that helps. Programming isn&#39;t my day job so I&#39;m not that great at it. Any help would be great.
<br><br><br>Thanks!<br><br>