<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>freeipa on Jack Henschel's Blog</title><link>https://blog.cubieserver.de/tags/freeipa/</link><description>Recent content in freeipa on Jack Henschel's Blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Fri, 06 Jul 2018 10:00:00 +0200</lastBuildDate><atom:link href="https://blog.cubieserver.de/tags/freeipa/index.xml" rel="self" type="application/rss+xml"/><item><title>Synology NAS: Samba, NFS and Kerberos with FreeIPA LDAP</title><link>https://blog.cubieserver.de/2018/synology-nas-samba-nfs-and-kerberos-with-freeipa-ldap/</link><pubDate>Fri, 06 Jul 2018 10:00:00 +0200</pubDate><guid>https://blog.cubieserver.de/2018/synology-nas-samba-nfs-and-kerberos-with-freeipa-ldap/</guid><description>&lt;p>&lt;em>This work is a collaboration with my colleague &lt;a href="https://martialblog.de/">Markus Opolka&lt;/a> (&lt;a href="https://github.com/martialblog/">@martialblog&lt;/a>).&lt;/em>&lt;/p>
&lt;p>Since we migrated our old, hacky LDAP server to a completely new FreeIPA instance, authenticating Samba and NFS users with the new LDAP server (provided by FreeIPA) was no longer possible.&lt;/p>
&lt;p>As we don&amp;rsquo;t have that many users, the short-term fix was to locally create the required accounts on the Synology NAS.
This has the disadvantage of splitting the password management, so we wanted to fix it.&lt;/p>
&lt;p>Unfortunately, Synology&amp;rsquo;s documentation on this issue is rather sparse.&lt;/p>
&lt;p>Here is what we found out through a lot of internet research, searching through log files and digging in the configuration.&lt;/p>
&lt;p>Before we begin: we are running Synology DSM 6.1 and FreeIPA 4.4.&lt;/p>
&lt;h2 id="samba">
&lt;a href="#samba">#
&lt;/a>&amp;nbsp;Samba
&lt;/h2>
&lt;ul>
&lt;li>The LDAP user accounts need &lt;code>sambaSamAccount&lt;/code> as &lt;code>objectClass&lt;/code>.&lt;/li>
&lt;li>&lt;code>sambaSamAccount&lt;/code> requires the following three attributes: &lt;code>sambaSID&lt;/code>, &lt;code>sambaAcctFlags&lt;/code> and &lt;code>sambaDomainName&lt;/code>&lt;/li>
&lt;li>&lt;code>sambaSID&lt;/code> is the unique id of the user, it follows a scheme like &lt;code>S-1-5-21-UID&lt;/code> where the last part is unique for each user (the rest is shared among the domain), more information: &lt;a href="https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems">https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems&lt;/a>&lt;/li>
&lt;li>&lt;code>sambaAcctFlags&lt;/code> is set to &amp;ldquo;[U           ]&amp;rdquo; (12 characters between the brackets!), more information: &lt;a href="http://pig.made-it.com/samba-accounts.html">http://pig.made-it.com/samba-accounts.html&lt;/a>&lt;/li>
&lt;li>&lt;code>sambaDomainName&lt;/code> is simply the domain name of your Samba domain (all caps).&lt;/li>
&lt;/ul>
&lt;p>Unfortunately, FreeIPA&amp;rsquo;s web interface does not allow setting &amp;lsquo;custom&amp;rsquo; attributes (like the ones shown above), hence users can no longer be created via the Web-UI (since the attributes are mandatory), but have to be created from the command line:&lt;/p>
&lt;pre>&lt;code>ipa user-add frankdoe --first=Frank --last=Doe --password --addattr=sambaSID=S-1-5-21-122 --addattr=sambaAcctFlags=[U ]
&lt;/code>&lt;/pre>&lt;p>Existing users can be modified with the following LDIF script:&lt;/p>
&lt;pre>&lt;code class="language-ldif" data-lang="ldif">dn: uid=johndoe,cn=users,cn=accounts,dc=example,dc=com
changetype: modify
add: objectClass
objectClass: sambaSamAccount
-
add: sambaSID
sambaSID: &amp;quot;S-1-5-21-123&amp;quot;
-
add: sambaAcctFlags
sambaAcctFlags: &amp;quot;[U ]&amp;quot;
-
add: sambaDomainName
sambaDomainName: &amp;quot;EXAMPLE.COM&amp;quot;
&lt;/code>&lt;/pre>&lt;p>and applied:&lt;/p>
&lt;pre>&lt;code>ldapmodify -h localhost -x -D &amp;quot;cn=Directory Manager&amp;quot; -W -f /path/to/samba.ldif
&lt;/code>&lt;/pre>&lt;p>&lt;strong>Important step&lt;/strong>: grant your LDAP service bind account access to the relevant attributes!&lt;/p>
&lt;ul>
&lt;li>Go to &amp;ldquo;IPA Server&amp;rdquo; and create a new role &amp;ldquo;File Server&amp;rdquo;&lt;/li>
&lt;li>Create a new privilege &amp;ldquo;Samba Authentication&amp;rdquo;&lt;/li>
&lt;li>Add a new permission &amp;ldquo;Read Samba Attributes&amp;rdquo; to this privilege&lt;/li>
&lt;li>Select the various Samba attributes listed&lt;/li>
&lt;li>Add the newly created role to the bind account&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="samba-permissions.png" alt="samba permissions">&lt;/p>
&lt;p>Since your users probably don&amp;rsquo;t have the &lt;code>NTPasswordHash&lt;/code> attribute set yet, they will have to reset (i.e. retype) their password in the Web-UI once, then FreeIPA will automatically set the password hash.&lt;/p>
&lt;h2 id="nfs">
&lt;a href="#nfs">#
&lt;/a>&amp;nbsp;NFS
&lt;/h2>
&lt;p>NFS authentication via LDAP and Kerberos was previously working, however we had trouble with the ID mappings.
If you have local users on the Synology NAS, you can manually map the UID (Control Panel -&amp;gt; File Services -&amp;gt; NFS -&amp;gt; Kerberos Settings -&amp;gt; ID Mapping), but then the users are still using the &amp;lsquo;local&amp;rsquo; password on the NAS.&lt;/p>
&lt;p>So let&amp;rsquo;s fix that, too!&lt;/p>
&lt;p>Since the NFS LDAP is not included with FreeIPA, get the UMICH schema from &lt;a href="http://www.citi.umich.edu/projects/nfsv4/crossrealm/libnfsidmap_config.html">http://www.citi.umich.edu/projects/nfsv4/crossrealm/libnfsidmap_config.html&lt;/a> (at the bottom of the page) and insert it into &lt;code>/etc/dirsrv/slapd/schema/99nfs.ldif&lt;/code>.&lt;/p>
&lt;pre>&lt;code class="language-ldif" data-lang="ldif">dn: cn=schema
attributeTypes: ( 1.3.6.1.4.1.250.1.61 NAME 'NFSv4Name' DESC 'NFS version 4 Name' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributeTypes: ( 1.3.6.1.4.1.250.1.62 NAME 'GSSAuthName' DESC 'RPCSEC GSS authenticated user name' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
objectClasses: ( 1.3.6.1.4.1.250.1.63 NAME 'NFSv4RemotePerson' DESC 'NFS version4 person from remote NFSv4 Domain' SUP top STRUCTURAL MUST ( uidNumber $ gidNumber $ NFSv4Name ) MAY ( cn $ GSSAuthName $ description) )
objectClasses: ( 1.3.6.1.4.1.250.1.64 NAME 'NFSv4RemoteGroup' DESC 'NFS version4 group from remote NFSv4 Domain' SUP top STRUCTURAL MUST ( gidNumber $ NFSv4Name ) MAY ( cn $ memberUid $ description) )
&lt;/code>&lt;/pre>&lt;ul>
&lt;li>The user accounts need &lt;code>NFSv4RemotePerson&lt;/code> as &lt;code>objectClass&lt;/code>&lt;/li>
&lt;li>&lt;code>GSSAuthName&lt;/code> needs to be set to &lt;code>username@EXAMPLE.COM&lt;/code>&lt;/li>
&lt;li>&lt;code>NFSv4Name&lt;/code> needs to be set to &lt;code>username@example.com&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>This can be achieved with this LDIF snippet:&lt;/p>
&lt;pre>&lt;code class="language-ldif" data-lang="ldif">dn: uid=johndoe,cn=users,cn=accounts,dc=example,dc=com
changetype: modify
add: objectClass
objectClass: NFSv4RemotePerson
-
add: GSSAuthName
GSSAuthName: johndoe@EXAMPLE.COM
-
add: NFSv4Name
NFSv4Name: johndoe@example.com
&lt;/code>&lt;/pre>&lt;p>and again applied with:&lt;/p>
&lt;pre>&lt;code>ldapmodify -h localhost -x -D &amp;quot;cn=Directory Manager&amp;quot; -W -f /path/to/nfs.ldif
&lt;/code>&lt;/pre>&lt;p>Again, we need to grant our LDAP service bind access to these &amp;lsquo;new&amp;rsquo; attributes.&lt;/p>
&lt;ul>
&lt;li>In the FreeIPA UI: Extend the previously created role &amp;ldquo;File Server&amp;rdquo;&lt;/li>
&lt;li>Create new privilege &amp;ldquo;Kerberos Authentication&amp;rdquo;&lt;/li>
&lt;li>Add new permission &amp;ldquo;Read NFS Attributes&amp;rdquo; to this privilege&lt;/li>
&lt;li>Grant &lt;code>read&lt;/code>, &lt;code>search&lt;/code> and &lt;code>compare&lt;/code> for the attributes &lt;code>GSSAuthName&lt;/code> and &lt;code>NFSv4Name&lt;/code>&lt;/li>
&lt;li>Note: Since these attributes are not native to FreeIPA, you have to type &lt;code>gssauthname&lt;/code> into &amp;ldquo;Effective Attributes&amp;rdquo;, hit &amp;ldquo;Add&amp;rdquo;, then insert the attribute name again (&amp;ldquo;Add Custom Attributes&amp;rdquo; dialog), hit enter and now (finally!) the attribute appears with a check box next to it - repeat for &lt;code>nfsv4name&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>By default, Synology NAS creates the home directory for the user at &lt;code>/home/@LH-${FQDN}/${some_number}/${user}-${uid}&lt;/code>.
But we don&amp;rsquo;t want to follow their scheme, therefore we disable the auto-creation of home directories on the NAS and manually create the home directory and set the owner to &lt;code>johndoe@example.com&lt;/code>.&lt;/p>
&lt;p>Don&amp;rsquo;t forget to synchronize the LDAP between your LDAP server and your NAS (Control Panel -&amp;gt; LDAP -&amp;gt; LDAP Users -&amp;gt; Update LDAP Data).&lt;/p>
&lt;p>One more thing: we strongly discourage using Synology&amp;rsquo;s Web-UI to modify the ownership of directories since it discards the modes of the files.
Rather, login via SSH and set the appropriate owner with &lt;code>chown&lt;/code>.&lt;/p>
&lt;h2 id="debugging">
&lt;a href="#debugging">#
&lt;/a>&amp;nbsp;Debugging
&lt;/h2>
&lt;p>If authentication is still not functioning, here are two tips for debugging:&lt;/p>
&lt;ul>
&lt;li>Use &lt;code>smbclient&lt;/code> from a Linux machine to connect the server, since its verbosity can be drastically increased (unlike Windows), e.g.: &lt;code>smbclient -d 10 -U johndoe //file-server-address/Share-Name&lt;/code>.&lt;/li>
&lt;li>Enable the verbose debug logs in Control Panel -&amp;gt; File Services -&amp;gt; SMB -&amp;gt; Advanced Settings -&amp;gt; Collect Debug Logs, log into the NAS via SSH and look at the logs under &lt;code>/var/log/samba/&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h2 id="references">
&lt;a href="#references">#
&lt;/a>&amp;nbsp;References
&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.freeipa.org/page/Howto/Integrating_a_Samba_File_Server_With_IPA">https://www.freeipa.org/page/Howto/Integrating_a_Samba_File_Server_With_IPA&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://aput.net/~jheiss/samba/ldap.shtml">https://aput.net/~jheiss/samba/ldap.shtml&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://bgstack15.wordpress.com/2017/05/10/samba-share-with-freeipa-auth/">https://bgstack15.wordpress.com/2017/05/10/samba-share-with-freeipa-auth/&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.redhat.com/archives/freeipa-users/2015-August/msg00137.html">https://www.redhat.com/archives/freeipa-users/2015-August/msg00137.html&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>