issue while doing pexpect ssh

Laura Creighton lac at
Tue Sep 8 18:43:40 CEST 2015

In a message of Tue, 08 Sep 2015 23:57:41 +1000, Chris Angelico writes:
>On Tue, Sep 8, 2015 at 9:37 PM,  <harirammanohar159 at> 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

This poor soul cannot login at all. He needs this hack to let him
su some-other-user because of a draconian policy he cannot do
anything about.  If he could just log in, one heck of a lot of
other things would be simpler for him ...


More information about the Python-list mailing list