issue while doing pexpect ssh

Chris Angelico rosuav at gmail.com
Tue Sep 8 09:57:41 EDT 2015


On Tue, Sep 8, 2015 at 9:37 PM,  <harirammanohar159 at gmail.com> wrote:
> Some where i am missing simple logic.... :)
>
> =====
> child = pexpect.spawn('ssh hari at hostname')
> child.logfile = sys.stdout
> child.expect('hari\'s Password: ')
> =====
>
> getting error as follows:
> ============
> child.expect('hari\'s Password: ')
> TypeError: must be str, not bytes
> ===========

Laura's already answered your actual question. But I would recommend
using public key login rather than keying in a password; it's a lot
more secure, as it means you don't have to embed a password in your
source code (or at very best, on your hard disk in some other readable
and decryptable way). It also simplifies the transaction
significantly.

ChrisA



More information about the Python-list mailing list