Using python with SSH?

Lawrence Oluyede raims at dot.com
Wed Dec 17 18:08:43 EST 2003


Steve <nospam at nopes> writes:

> ssh -l user host "/path/to/program"
>
> prompts for a password and I don't know how to supply one via a python
> script. Is there an easy way out? Can I log onto to the other machine via
> ssh somehow? Does a python script support this? Thanks!

Try something like this:

import os

ssh_pipe = os.popen("ssh -l user path")
ssh_pipe.write(password)
ssh_pipe.write("\n")
ssh_pipe.flush()
ssh_pipe.close()

hope this helps

-- 
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com




More information about the Python-list mailing list