SSH using PEXPECT

yellowblueyellow at gmail.com yellowblueyellow at gmail.com
Thu Sep 11 03:04:42 CEST 2008


Hey , I need to SSH into a server .. (10.8.42.38) using pexpect the
username is 'admin' and password is 'abc123' so far i have the
following code


import pexpect
import sys
import time
import os


foo = pexpect.spawn('ssh admin at 10.8.42.38')
ssh_newKey = 'Are you sure you want to continue connecting'

foo.expect = ssh_newKey
foo.send = 'yes'
foo.expect = 'password:'
foo.send = 'abc123'

-------------------------------------------------------------------------------------------------

does this look right?

if not , could someone suggest a way to do this ..
your help is much appreciated




More information about the Python-list mailing list