开发者

Python Unix authentication

I need to do a simple authentication of username's which are on the host and NIS. I am writing this code in Python.

I tried using PAM to do authentication. For this I downloaded a Python module called Python Pam.

The code I use :

import pam   
pam.authenticate('root',<password>,<service>)

where <service> is a config file I created in /etc/pam.d/

the file contains the following code

#%PAM-1.0
auth     requisite      pam_unix.so

This code works on certain hosts giving the correct answer, but n开发者_C百科ot on others

Even if I replaced <service> with login or sshd as in

pam.authenticate('root',<password>,'sshd')

It still returns False for a correct password on certain hosts.

So does anybody know why this does not work. I don't need to use pam or any module. Is there any command in unix that I can invoke from Python which would just authenticate a username? and preferably work across all unix based systems including Linux, Solaris, HP-UX, AIX.

Thanks


Both

 pam.authenticate('myusername', 'mypassword', 'sshd')

and

 pam.authenticate('myusername', 'mypassword')

Login works fine on my machine. The documentation for the pam module is pretty much non-existent, so if you configured your service correctly or not is hard for me to say.


The answer to that lies in the third parameter in the /etc/pam.d/ file you created.

Try this command on the machines where it does not work. Yes, you must be root or sudoer root.

# ldconfig -v |grep pam_unix.so

Most likely a symlink does not lead to the real pam shared library from pam_unix.so. Add it or change the config file parameter to something that ld can use to find the link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜