[mdlug] Programatically Answering a Password Prompt

Wojtak, Greg GregWojtak at quickenloans.com
Fri Aug 8 13:47:21 EDT 2014


Thanks everyone for the tips.

Gregory - With kerberos, keytabs are definitely the way to go, but for
what I¹m doing, I need to be able to accept password or keytab.

Aaron and John - I knew about expect and didn¹t want to have to rely on
expect or the python pexpect module to be installed if I didn¹t have to.
BUT, I took a look at the pexpect module to see how it worked, and I was
able to figure it out (by gratuitously ³borrowing² code).

Thanks for all the pointers, I think I¹m all set!

Greg

On 8/8/14, 11:41 AM, "Gregory Czerniak" <gregczrk at gmail.com> wrote:

>Hi Greg,
>
>    I believe you can solve your problem more elegantly by using a
>keytab file to supply credentials to Kerberos rather than trying to
>pipe a password into kinit.
>    Here are two tutorials on how to do this:
>
>- 
>http://www.microhowto.info/howto/add_a_host_or_service_principal_to_a_keyt
>ab_using_mit_kerberos.html
>- http://xteams.oit.ncsu.edu/iso/node/814
>
>Thanks,
>Greg Czerniak
>
>On Thu, Aug 7, 2014 at 12:38 PM, Wojtak, Greg
><GregWojtak at quickenloans.com> wrote:
>> I¹m writing  a python script and part of it is calling kinit to get a
>>kerberos ticket before doing some ldap operations.  I¹m trying to find a
>>method to pass the password into my script, and I haven¹t been able to
>>reliably do this.  Depending on the distribution of Linux and the
>>version of that distribution, I¹ve found that different versions of
>>kinit will read the password:
>>
>>
>>   *   From STDIN
>>   *   From a file descriptor dup()¹ed from STDIN
>>   *   By opening /dev/tty and polling directly for key presses/input
>>
>> I have been able to get the first two cases covered, but I am at a loss
>>as to how to get the third case going.  I¹ve even tried firing off the
>>kinit and then writing directly to /dev/tty, but as expected, that does
>>not work.  If it helps, I am using the python subprocess module with
>>Popen to run kinit, but as far as I know, there is no method to redirect
>>anything other than file descriptors 0, 1, and 2 with Popen.
>>
>> Does anyone have any insight into this?  Even if you¹re not a python
>>programmer, if you know how this is working, any insight you could give
>>would be much appreciated.
>>
>> TIA,
>>
>> Greg
>> _______________________________________________
>> mdlug mailing list
>> mdlug at mdlug.org
>> http://mdlug.org/mailman/listinfo/mdlug
>_______________________________________________
>mdlug mailing list
>mdlug at mdlug.org
>http://mdlug.org/mailman/listinfo/mdlug



More information about the mdlug mailing list