2

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 not 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

1
  • Is it possible for you to conduct further trials with other usernames? For example, the usual default configuration of sshd won't allow root at all, as a security measure. Commented Jan 3, 2011 at 19:13

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.