Using ssh instead on telnetlib ... what are the ways

Amol Sonaikar amol at kenati.com
Mon Dec 30 08:03:15 EST 2002


Hi All

We are using a script and passing and ip address and filename to it. We are 
using Telnetlib to write our commands on the telnet instance. We need to use 
SSH instead of telnet now.  Some part I have posted below.
-----------------------------------------------------------------------------
#!/usr/bin/env python2.1
import sys
import telnetlib
import os

tn = telnetlib.Telnet("")

tn.open( sys.argv[1] )
tn.write( "/usr/sbin/cli\n" )
tn.read_until("Username: ")
tn.write("admin\n")
tn.read_until("Password: ")
tn.write("admin\n")
------------------------------------------------------------------------------

I am using telnet variable only to connect to, write on the application which 
I opened using telnet. What library or method I should use so thet I can 
access and connect using 'ssh' ???

I have tried os.system but it directly executes and opens prompt in front 
where it has to do it on backend. How can I use any other method ???




More information about the Python-list mailing list