Search code examples
pythonsshtimeoutscppexpect

Python pexpect timeout when entering password on scp command


I dont know how to describe it, just nothing happens in a while and then suddenly I get this. Im new with this module and I really dont know why I get this error: pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
My code:

import pexpect 
child = pexpect.spawn('scp abc user@ip:')
child.expect('Password .*:')
child.sendline('pwd')

Solution

  • What happens when you try:

    child.expect('Password .*:', timeout=None)