Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check username/password in Linux without root

If I have a username and password pair how can I verify that they are actually correct in a Linux system? I know I can use passwd to do so but I want to do it programatically using C.

I should not require root privileges (so reading the shadow file is not an option).

Thank you.

like image 894
user1618465 Avatar asked Oct 27 '25 06:10

user1618465


1 Answers

If you are using a PAM, you might be able to make use of checkpassword-pam.

The manual has an example command (with debugging) which should give you a good place to start.

echo -e "username\0password\0timestamp\0" \
    | checkpassword-pam -s SERVICE \
    --debug --stdout -- /usr/bin/id 3<&0
like image 176
Matt Clark Avatar answered Oct 29 '25 21:10

Matt Clark