How can I use PHP to authenticate Linux users and passwords?

Let's say I wanted to create something like the way cPanel works, it uses the username and password from the system.

You can run "passwd user" on the server, and the password will work with cPanel and FTP (not necessarily MySQL, but you will get the point)

How would this be done in PHP? I have no idea other than running / bin / su locally and working on it. However, this may be inaccurate, although .. Usually I have several of my developers either on a sub-account or on something to learn.

Any ideas would be greatly appreciated, thanks! :)

+5
source share
2 answers

PAM: http://pecl.php.net/package/PAM

Debian/'buntu , , , php5-auth-pam :

pam_auth($username,$password,$error);

, , php4, " , :

if(!pam_auth($username,$password,&$error)){
    echo 'No access, PAM said: '.$error;
}
+6

, . PAM PHP: http://pecl.php.net/package/PAM

PHP: posix_getpwnam

.

0

All Articles