6

I set up remote LDAP server (Server1) and SSH with pam_ldap on Server2. Everything is working ok, I can login to SSH with LDAP credentials. But when I want to add new user, I have to firstly create it in LDAP databases and then run adduser on Server2.

How can I automatically create the user account on Server2 after adding it to LDAP database ? For example when the user first logs in? Thanks.

12

You don't need to actually make the user on the server2, only their home directory on first login. You're looking for pam_mkhomedir:

http://www.linux-pam.org/Linux-PAM-html/sag-pam_mkhomedir.html

Google will find you many howtos and examples on getting this set up.

  • the link is already dead :( – Darryl R. Norbert May 3 at 7:34
  • I've updated the URL. "already" is a linguistic stretch, this comment is 9 years old. – troyengel May 10 at 12:17
1

Have you enabled the LDAP module for NSS?

See here on how to do this: http://wiki.debian.org/LDAP/NSS

0

Actually, I found a working procedure for Debian on this page

Here it is:

Create /usr/share/pam-configs/mkhomedir file

Fill it with the following content:

Name: Create home directory during login
Default: yes
Priority: 900
Session-Type: Additional
Session:
        required        pam_mkhomedir.so umask=0022 skel=/etc/skel

Run the following command as root (or sudo) to update PAM configuration:

pam-auth-update

Login with non-existing user should now create it on the target system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.