SSH/Telnet program to Router/switch

S

Sujith S

Hi,

I am new to programming and python. I am looking for a python script to do ssh/telnet to a network equipment ? I know tcl/perl does this using expect/send.

Do we have expect available in python as well or need to use some other method ?

Regards
Sujith
 
W

Wojciech Åysiak

Hi,

I am new to programming and python. I am looking for a python script to do ssh/telnet to a network equipment ? I know tcl/perl does this using expect/send.

Do we have expect available in python as well or need to use some other method ?

Hello,
If you are looking for a way to connect to your netdevices and then
execute some shell commands (with output) via ssh then google for
paramiko module for python.

It works on windows and linux.
 
C

Chris Angelico

Hi,

I am new to programming and python. I am looking for a python script to do ssh/telnet to a network equipment ? I know tcl/perl does this using expect/send.

Do we have expect available in python as well or need to use some other method ?

Yep! Look up the socket module. Straight-forward TCP sockets are
usually easy enough to work.

ChrisA
 
J

Johannes Schneider

Hi,

I am new to programming and python. I am looking for a python script to do ssh/telnet to a network equipment ? I know tcl/perl does this using expect/send.

Do we have expect available in python as well or need to use some other method ?

Regards
Sujith



I'm using paramiko to access some routers and firewalls from python and
it works very well.

bg,
Johannes


--
Johannes Schneider
Webentwicklung
(e-mail address removed)
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
 
R

Roy Smith

Sujith S said:
Hi,

I am new to programming and python. I am looking for a python script to do
ssh/telnet to a network equipment ? I know tcl/perl does this using
expect/send.

Do we have expect available in python as well or need to use some other
method ?

You want two libraries.

First, the low-level paramiko (http://www.lag.net/paramiko/) which
handles all the basic ssh connection stuff.

Next, fabric (http://docs.fabfile.org/en/1.8/), which layers a very easy
to use application layer on top of paramiko. Fabric is most commonly
used in conjunction with a near command-line driver tool called fab, but
you can also work directly with the library layer
(http://docs.fabfile.org/en/1.8/usage/library.html).

Fabric rocks. Don't waste your time with anything else (but see the
next paragraph).

As far as I know, fabric only works with ssh. If you are forced to use
telnet to talk to legacy equipment, that's another problem.
 
C

Chris Angelico

As far as I know, fabric only works with ssh. If you are forced to use
telnet to talk to legacy equipment, that's another problem.

If it's telnet, it's likely to be a pretty simple protocol. All you
really need is the socket module, build it all yourself. Networking's
easy enough to handle; it's the crypto on top of it (SSH, in your
case) that's not worth doing manually.

ChrisA
 
F

Ferrous Cranus

Τη ΤετάÏτη, 19 ΦεβÏουαÏίου 2014 10:45:53 Ï€.μ. UTC+2, ο χÏήστης Wojciech Åysiak έγÏαψε:
Hello,

If you are looking for a way to connect to your netdevices and then

execute some shell commands (with output) via ssh then google for

paramiko module for python.



It works on windows and linux.



--

BR,

Wojtek

Hello,

What will benefit the OP to go ahead and use paramiko opposed to just use "Putty" or another perhaps even Chrome based ssh client?

Is there an advantage to that?
 
R

Rodrick Brown

Sent from my iPhone
Hello,

What will benefit the OP to go ahead and use paramiko opposed to just use "Putty" or another perhaps even Chrome based ssh client?

Is there an advantage to that?
This is a Python mailing list so obviously the OP wants to use python to automate logging into his devices and dispatching some commands. Why else wouldthey ask here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top