Python SSHv2 to Cisco routers for multiple commands

Sam Crooks <[email protected]> Tue, 10 Mar 2009 11:24:42 -0500
Newsgroups gmane.network.toolmakers
Message-ID <[email protected]>
--===============7868216393064338458==
Content-Type: multipart/alternative; boundary=0016e64604763d02e30464c6309a

--0016e64604763d02e30464c6309a
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Does anyone have any suggestions for SSHv2 to multiple Cisco devices and
(this is the catch) running multiple commands?

I've tried with Paramiko using the SSHClient(), then connect()'ing and
issuing exec_command(), and it seems that the router closes the channel
after the .exec_command('command here').  Subsequent write()'s on the stdin
file object returned do not work, as shown on the examples I have seen:
http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/#more-465


I've tried various examples with twisted.conch.ssh and it seems Twisted is a
bit more low-level than paramiko's SSHClient class.



I'm trying to  be able to issue a string of commands to routers which
require a particular sequence;

configure terminal
hostname blahrouter1
ip domain-name x.i.z

ip tftp source-interface lo0
end


copy tftp:/x.y.z.w/my/path/file.txt   flash:

--0016e64604763d02e30464c6309a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>Does anyone have any suggestions for SSHv2 to multiple Cisco devices a=
nd (this is the catch) running multiple commands?</div>
<div>=A0</div>
<div>I&#39;ve tried with Paramiko using the SSHClient(), then connect()&#39=
;ing and issuing exec_command(), and it seems that the router closes the ch=
annel after the .exec_command(&#39;command here&#39;).=A0 Subsequent write(=
)&#39;s on the stdin file object returned do not work, as shown on the exam=
ples I have seen:=A0 <a href=3D"http://jessenoller.com/2009/02/05/ssh-progr=
amming-with-paramiko-completely-different/#more-465">http://jessenoller.com=
/2009/02/05/ssh-programming-with-paramiko-completely-different/#more-465</a=
></div>

<div>=A0</div>
<div>=A0</div>
<div>I&#39;ve tried various examples with twisted.conch.ssh and it seems Tw=
isted is a bit more low-level than paramiko&#39;s SSHClient class.</div>
<div>=A0</div>
<div>=A0</div>
<div>=A0</div>
<div>I&#39;m trying to=A0 be able to issue a string of commands to routers =
which require a particular sequence;</div>
<div>=A0</div>
<div>configure terminal</div>
<div>hostname blahrouter1</div>
<div>ip domain-name x.i.z</div>
<div>=A0</div>
<div>ip tftp source-interface lo0</div>
<div>end</div>
<div>=A0</div>
<div>=A0</div>
<div>copy tftp:/x.y.z.w/my/path/file.txt=A0=A0 flash:</div>
<div>=A0</div>
<div>=A0</div>
<div>=A0</div>
<div>=A0</div>

--0016e64604763d02e30464c6309a--

--===============7868216393064338458==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Toolmakers mailing list
[email protected]
https://lists.isc.org/mailman/listinfo/toolmakers
--===============7868216393064338458==--