How to Authenticate a Linux Desktop to Your OpenLDAP Server - Printable Version +- Sick Gaming (https://www.sickgaming.net) +-- Forum: Computers (https://www.sickgaming.net/forum-86.html) +--- Forum: Linux, FreeBSD, and Unix types (https://www.sickgaming.net/forum-88.html) +--- Thread: How to Authenticate a Linux Desktop to Your OpenLDAP Server (/thread-89664.html) |
How to Authenticate a Linux Desktop to Your OpenLDAP Server - xSicKxBot - 04-06-2019 How to Authenticate a Linux Desktop to Your OpenLDAP Server <div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/04/how-to-authenticate-a-linux-desktop-to-your-openldap-server.jpg" width="1280" height="640" title="" alt="" /></div><div><div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/04/how-to-authenticate-a-linux-desktop-to-your-openldap-server.jpg" class="ff-og-image-inserted"></div> <p>In this final part of our three-part series, we reach the conclusion everyone has been waiting for. The ultimate goal of using LDAP (in many cases) is enabling desktop authentication. With this setup, admins are better able to manage and control user accounts and logins. After all, Active Directory admins shouldn’t have all the fun, right?</p> <p>WIth OpenLDAP, you can manage your users on a centralized directory server and connect the authentication of every Linux desktop on your network to that server. And since you already have <a href="https://www.linux.com/blog/2019/3/how-install-openldap-ubuntu-server-1804">OpenLDAP</a> and the <a href="https://www.linux.com/blog/learn/2019/3/how-install-ldap-account-manager-ubuntu-server-1804">LDAP Authentication Manager</a> setup and running, the hard work is out of the way. At this point, there is just a few quick steps to enabling those Linux desktops to authentication with that server.</p> <p>I’m going to walk you through this process, using the Ubuntu Desktop 18.04 to demonstrate. If your desktop distribution is different, you’ll only have to modify the installation steps, as the configurations should be similar.</p> <p><strong>What You’ll Need</strong></p> <p>Obviously you’ll need the OpenLDAP server up and running. You’ll also need user accounts created on the LDAP directory tree, and a user account on the client machines with sudo privileges. With those pieces out of the way, let’s get those desktops authenticating.</p> <p><strong>Installation</strong></p> <p>The first thing we must do is install the necessary client software. This will be done on all the desktop machines that require authentication with the LDAP server. Open a terminal window on one of the desktop machines and issue the following command:</p> <pre> sudo apt-get install libnss-ldap libpam-ldap ldap-utils nscd -y </pre> <p>During the installation, you will be asked to enter the LDAP server URI (<strong>Figure 1</strong>). </p> <p>The LDAP URI is the address of the OpenLDAP server, in the form ldap://SERVER_IP (Where SERVER_IP is the IP address of the OpenLDAP server). Type that address, tab to OK, and press Enter on your keyboard.</p> <p>In the next window (<strong>Figure 2</strong><strong>)</strong>, you are required to enter the Distinguished Name of the OpenLDAP server. This will be in the form dc=example,dc=com. </p> <p>If you’re unsure of what your OpenLDAP DN is, log into the LDAP Account Manager, click Tree View, and you’ll see the DN listed in the left pane (<strong>Figure 3</strong>).</p> <p>The next few configuration windows, will require the following information:</p> <ul> <li> <p>Specify LDAP version (select 3)</p> </li> <li> <p>Make local root Database admin (select Yes)</p> </li> <li> <p>Does the LDAP database require login (select No)</p> </li> <li> <p>Specify LDAP admin account suffice (this will be in the form cn=admin,dc=example,dc=com)</p> </li> <li> <p>Specify password for LDAP admin account (this will be the password for the LDAP admin user)</p> </li> </ul> <p>Once you’ve answered the above questions, the installation of the necessary bits is complete.</p> <p><strong>Configuring the LDAP Client</strong></p> <p>Now it’s time to configure the client to authenticate against the OpenLDAP server. This is not nearly as hard as you might think.</p> <p>First, we must configure nsswitch. Open the configuration file with the command:</p> <pre> sudo nano /etc/nsswitch.conf</pre> <p>In that file, add ldap at the end of the following line:</p> <pre> passwd: compat systemd group: compat systemd shadow: files</pre> <p>These configuration entries should now look like:</p> <pre> passwd: compat systemd ldap group: compat systemd ldap shadow: files ldap</pre> <p>At the end of this section, add the following line:</p> <pre> gshadow files</pre> <div> <p>The entire section should now look like:</p> <pre> passwd: compat systemd ldap group: compat systemd ldap shadow: files ldap gshadow files</pre> <p>Save and close that file.</p> <p>Now we need to configure PAM for LDAP authentication. Issue the command:</p> <pre> sudo nano /etc/pam.d/common-password</pre> <p>Remove use_authtok from the following line:</p> <pre> password [success=1 user_unknown=ignore default=die] pam_ldap.so use_authtok try_first_pass</pre> <p>Save and close that file.</p> <p>There’s one more PAM configuration to take care of. Issue the command:</p> <pre> sudo nano /etc/pam.d/common-session</pre> <p>At the end of that file, add the following:</p> <pre> session optional pam_mkhomedir.so skel=/etc/skel umask=077</pre> <p>The above line will create the default home directory (upon first login), on the Linux desktop, for any LDAP user that doesn’t have a local account on the machine. Save and close that file.</p> <p><strong>Logging In</strong></p> <p>Reboot the client machine. When the login is presented, attempt to log in with a user on your OpenLDAP server. The user account should authenticate and present you with a desktop. You are good to go.</p> <p>Make sure to configure every single Linux desktop on your network in the same fashion, so they too can authenticate against the OpenLDAP directory tree. By doing this, any user in the tree will be able to log into any configured Linux desktop machine on your network.</p> <p>You now have an OpenLDAP server running, with the LDAP Account Manager installed for easy account management, and your Linux clients authenticating against that LDAP server.</p> <p>And that, my friends, is all there is to it.</p> <p>We’re done.</p> <p>Keep using Linux.</p> <p>It’s been an honor.</p> </div> </div> |