0

I have been looking everywhere for this and have not found a solution. I am using python 2.5.1 on an Apple iPod and I am trying to connect to a host with SSH. First I start off with import os. Next I os.system('ssh 192.168.1.13). After this command is executed I next try to os.system('password'). This does not work and SSH asks for the password, after I exit the SSH session then my password is printed. Is there any way that I can get it so that it sends the password to SSH? I don't want to add any other modules to python. Thanks!

Complete file:

import os

os.system('ssh 192.168.1.13')
os.system('password')

2 Answers 2

2

take a look at pexpect, it should do the trick in the manner you expect it.

Example from the docs:

child = pexpect.spawn('scp foo [email protected]:.')
child.expect ('Password:')
child.sendline (mypassword)

Yes, that's yet another module.. but the cleanest way to accomplish what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

This is perfect! I guess I can make an exception and get a new module. Thanks!
0

Or use passwordless, passphraseless ssh: http://stromberg.dnsalias.org/~strombrg/ssh-keys.html

No additional module required.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.