[paramiko] migrate from Telnet to SSH

James Bardin jbardin at bu.edu
Wed Jul 11 07:00:42 PDT 2007


Hi Chris,

Take a look in the SSHClient class (download the most recent version 
though).  You don't have to use an interactive shell. The SSHClient 
class also does nice things like handle an ssh-agent if available, and 
try to use your private keys if they're not encrypted.

A *real* basic example:

############################
import paramiko

client = paramiko.SSHClient()

# ignore host keys for the test
client.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())

client.connect('hostname', 22, 'username', 'Passw0rd')

(stdin, stdout, stderr) = client.exec_command('command')
print stdout.read()
############################


-jim


Chris Hallman wrote:
> I've written numerous programs that utilize Telnet to gather data, 
> reload,
> or reconfigure network devices. I didn't use an interactive session 
> like the
> demo SSH scripts use. I had the program issuing the commands.
>
> We're migrating from Telnet to SSH. I was hoping to find some examples 
> where
> the program is interacting with the remote device but isn't using a 
> shell.
> Does anyone have a program similar to what I described that I could 
> look at?
>
>
>
> Thanks!!
>




More information about the paramiko mailing list