I struggle a little bit with setting up ldap authentification on Ubuntu 20.04. I followed this guide, that is, I installed the packages libnss-ldap libpam-ldap ldap-utils nscd
.
nsswitch.conf
looks
passwd: files systemd ldap
group: files systemd ldap
shadow: files ldap
gshadow: files
I changed the line in /etc/pam.d/common-password
so that it reads
password [success=1 user_unknown=ignore default=die] pam_ldap.so try_first_pass
And I added the following line to /etc/pam.d/common-session
:
session optional pam_mkhomedir.so skel=/etc/skel umask=022
Now I'm not sure about whether it is necessary that the user exists locally or not. If the user exists, everything works fine. If not, I get the following messages in auth.log:
Jan 27 07:06:55 myserver sshd[4479]: Invalid user myuser from xxxx:xxx:xxxx:xxx::xx port 50556
Jan 27 07:07:03 myserver sshd[4479]: pam_unix(sshd:auth): check pass; user unknown
Jan 27 07:07:03 myserver sshd[4479]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=xxxx:xxx:xxxx:xxx::xx
Jan 27 07:07:03 myserver sshd[4479]: pam_ldap: error trying to bind as user "CN=myuser,OU=Users,OU=TEST,DC=ad,DC=test,DC=example,DC=de" (Invalid credentials)
Jan 27 07:07:05 myserver sshd[4479]: Failed password for invalid user myuser from xxxx:xxx:xxxx:xxx::xx port 50556 ssh2
Am I doing something wrong, and the user should be automatically created (if not existing locally) or is it working as expected, and I have to create the users beforehand?