<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Opinsys In English</title>
	<atom:link href="http://www.opinsys.fi/en/feed" rel="self" type="application/rss+xml" />
	<link>http://www.opinsys.fi/en</link>
	<description>Supporting learning in schools with Linux</description>
	<lastBuildDate>Wed, 05 May 2010 13:05:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>smbkrb5pwd &#8211; password syncing for OpenLDAP, MIT kerberos and Samba</title>
		<link>http://www.opinsys.fi/en/smbkrb5pwd-password-syncing-for-openldap-mit-kerberos-and-samba</link>
		<comments>http://www.opinsys.fi/en/smbkrb5pwd-password-syncing-for-openldap-mit-kerberos-and-samba#comments</comments>
		<pubDate>Wed, 05 May 2010 13:05:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[mit kerberos]]></category>
		<category><![CDATA[OpenLDAP]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1407</guid>
		<description><![CDATA[Here at Opinsys we&#8217;ve been busy trying to figure out how to make user management work easily without having to use ugly tricks to glue different applications together. Changing password sounds really simple to many, but it often gets quite complicated as there are many passwords that need to be changed. It is possible to [...]]]></description>
			<content:encoded><![CDATA[<p>Here at Opinsys we&#8217;ve been busy trying to figure out how to <a href="../itch-for-better-user-management-in-ubuntu">make user management work easily</a> without having to use ugly tricks to glue different applications  together. Changing password sounds really simple to many, but it often  gets quite complicated as there are many passwords that need to be  changed. It is possible to write a script to change the different  passwords at the same time, but that limits password changing to that  single script. Using GUI programs through PAM or Moodle to change the  password require a different approach.</p>
<p>In <a href="../openldap-authentication-with-kerberos-backend-using-sasl">earlier posting</a> I went through the setup for using SASL to get rid of  one password, but that left us still with Samba passwords to be changed  separately. As one commenter noted, there has been for a long time an OpenLDAP  overlay called smbk5pwd that syncs Heimdal kerberos and Samba passwords  automatically when the password is changed in OpenLDAP. It works by  intercepting the ldap exop password change operations and doing its own  magic. We&#8217;ve been using MIT Kerberos until now and as it is the better  maintained kerberos implementation in Ubuntu, we wanted to keep using  it.</p>
<p>As there was no existing solution like smbk5pwd for it, we decided  to implement one. smbk5pwd modifies the kerberos keys directly in the  database, but we were not brave enough to try the same with MIT Kerberos  and instead chose to use kadmind to create the principals in ldap. This approach uses extra network connections and it is possible that  changing password fails because connecting kadmind fails or kadmind  cannot connect back to ldap. Having a system where ldap server connects  to kerberos server that connects back to ldap is not an optimal  solution, but so far we haven&#8217;t seen problems arising from this. On the  other hand not having to deal with kerberos internals is a definite  plus.</p>
<p style="text-align: center"><img class="size-full wp-image-1415 aligncenter" src="http://www.opinsys.fi/en/files/2010/05/smbkrb5pwd.png" alt="smbkrb5pwd" width="535" height="180" /></p>
<p>If you are brave enough, here are quick instructions on how to use  the overlay. This is now the first version of the overlay and it has not  been in production use anywhere. It&#8217;s still missing features and ACLs  need to be checked out, so this is work in progress.</p>
<h3><a name="LDAP-kirjoituksia-Installationinstructions"></a>Installation  instructions</h3>
<p>The source code for smbkrb5pwd overlay is available <a href="/wp-content/uploads/2010/05/smbkrb5pwd-2010-05-05-r1.tgz">here</a>.</p>
<p>To compile the overlay the easiest way is to get the full source code  for OpenLDAP and place the smbkrb5pwd directory under  contrib/slapd-modules directory. After compiling OpenLDAP normally the  overlay can be compiled simply by:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>cd contrib/slapd-modules

make
sudo cp .libs/* /usr/lib/ldap/</pre>
</div>
<p>A precompiled version of smbkrb5pwd for Ubuntu 10.04 (Lucid Lynx) is  available from <a href="https://launchpad.net/~opinsys/+archive/ppa">Opinsys PPA in Launchpad</a>:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo apt-get install slapd-smbkrb5pwd</pre>
</div>
<p>To configure the overlay, the module needs to be loaded and  configured for the database.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>dn: cn=module{0},cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: {0}back_hdb
olcModuleload: {1}smbkrb5pwd</pre>
</div>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>dn: olcOverlay={0}smbkrb5pwd
objectClass: olcOverlayConfig
objectClass: olcSmbKrb5PwdConfig
olcOverlay: {0}smbkrb5pwd
olcSmbKrb5PwdEnable: samba
olcSmbKrb5PwdEnable: krb5
olcSmbKrb5PwdMustChange: 2592012
olcSmbKrb5PwdKrb5Realm: EDU.EXAMPLE.ORG
olcSmbKrb5PwdRequiredClass: posixAccount</pre>
</div>
<p>The overlay accepts the following configuration attributes:</p>
<div class="table-wrap">
<table class="confluenceTable" border="0">
<tbody>
<tr>
<td class="confluenceTd"><strong>Attribute</strong></td>
<td class="confluenceTd"><strong>Possible values</strong></td>
<td class="confluenceTd"><strong>Description</strong></td>
</tr>
<tr>
<td class="confluenceTd">olcSmbKrb5PwdEnable</td>
<td class="confluenceTd">samba / krb5</td>
<td class="confluenceTd">Enable samba/kerberos functionality of the  module, same as olcSmbK5PwdEnable in smbk5pwd. If attribute is not set or both are set, both passwords are changed.</td>
</tr>
<tr>
<td class="confluenceTd">olcSmbKrb5PwdMustChange</td>
<td class="confluenceTd">e.g. 31536000 (year), 2592000 (30 seconds)</td>
<td class="confluenceTd">Time in seconds before the password expires (currently affects only Samba)</td>
</tr>
<tr>
<td class="confluenceTd">olcSmbKrb5PwdKrb5Realm</td>
<td class="confluenceTd">e.g. EDU.EXAMPLE.ORG</td>
<td class="confluenceTd">Kerberos realm used to create user principals</td>
</tr>
<tr>
<td class="confluenceTd">olcSmbKrb5PwdRequiredClass</td>
<td class="confluenceTd">e.g. posixAccount</td>
<td class="confluenceTd">If set, the entry needs to have this object  class for the kerberos principal and samba passwords to be modified</td>
</tr>
</tbody>
</table>
</div>
<p>smbkrb5pwd connects to kadmind using a principal found in keytab file  /etc/ldap/slapd.d/openldap-krb5.keytab. The keytab is searched for  principal that has name smbkrb5pwd/FQDN@REALM. Note that &#8220;hostname -f&#8221;  should return fqdn. One way to achieve this is to put fqdn as the first  name in /etc/hosts for the server&#8217;s ip address (here 10.11.12.13):</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>10.11.12.13   server.edu.example.org server</pre>
</div>
<p>Creating the principal and exporting it to a keytab file can be done  with the following commands:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo kadmin.local -q <span class="code-quote">"addprinc -randkey smbkrb5pwd/server.edu.example.org@EDU.EXAMPLE.ORG"</span>
sudo kadmin.local -q "ktadd -e des-cbc-crc:normal -k /etc/ldap/slapd.d/openldap-krb5.keytab \
 smbkrb5pwd/server.edu.example.org@EDU.EXAMPLE.ORG"

sudo chown openldap.openldap /etc/ldap/slapd.d/openldap-krb5.keytab</pre>
</div>
<p>The overlay activates itself when an password change exop request is  made. This can be done for example with ldappasswd command:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>ldappasswd -x -D uid=admin,ou=people,dc=edu,dc=example,dc=org -W \
 uid=user1,ou=people,dc=edu,dc=example,dc=org</pre>
</div>
<p>smbkrb5pwd writes debug information to slapd&#8217;s logfile which is  normally /var/log/syslog in Ubuntu.</p>
<p>Happy hacking!</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/smbkrb5pwd-password-syncing-for-openldap-mit-kerberos-and-samba/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Itch for better user management in Ubuntu</title>
		<link>http://www.opinsys.fi/en/itch-for-better-user-management-in-ubuntu</link>
		<comments>http://www.opinsys.fi/en/itch-for-better-user-management-in-ubuntu#comments</comments>
		<pubDate>Wed, 21 Apr 2010 09:15:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[blueprint]]></category>
		<category><![CDATA[cas]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[OpenLDAP]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1293</guid>
		<description><![CDATA[There are a lot of tools for managing users in linux system. A lot of them. And judging by the number of Launchpad blueprints around the topic, there is also a lot of interest to improve Ubuntu&#8217;s user management infrastructure. Here at Opinsys we&#8217;ve been working with LDAP/kerberos for some years and although the situation [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of tools for managing users in linux system. A lot of  them. And judging by the number of Launchpad blueprints around the  topic, there is also a lot of interest to improve Ubuntu&#8217;s user management infrastructure. Here at Opinsys we&#8217;ve  been working with LDAP/kerberos for some years  and although the  situation has been getting better, there are still a lot of rough edges.  It is possible to get complex desktop setups working nicely, but  right now the invasion of web applications is reshaping the scene again.</p>
<p>I described some of the problems around the topic in my earlier blog  postings:</p>
<ul>
<li><a href="../user-management-rethought">User management rethought</a></li>
<li><a href="../en-laptops-in-schools">Shared and personal laptops in schools</a></li>
</ul>
<p>What we currently need for ourselves is a dead simple user management  tool that allows centralised management of the servers, but allows the  administration access for the users to be split between schools. Usually  there are a few people in every school who are responsible for managing  the users for their own school. Often a single directory has user  information for multiple schools and for various reasons it is not  always desirable to show the user information for administrators in other schools. And of course everything on the web should integrate to it automatically. We are itching to do something about this.</p>
<p>A common situation that we have right now in schools is something  like this. Several schools share an ltsp cluster and an authentication server. Single server manages users for several schools and web applications hosted elsewhere authenticate against the district&#8217;s server.</p>
<p style="text-align: center"><img class="size-full wp-image-1292 aligncenter" src="http://www.opinsys.fi/en/files/2010/04/school_example1.png" alt="school_example1" width="501" height="335" /></p>
<p>I had a quick look at different blueprints around the topic in Launchpad and found the  following. I&#8217;m sure there are many more around the topic, but these  describe the problem area quite well. Unfortunately only a few features  have been implemented.</p>
<div>
<table border="1">
<tbody>
<tr>
<th>Blueprint</th>
<th>Issues discussed in the blueprint</th>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/edubuntu-mass-maintenance">Find tools to maintain large  deployments</a></td>
<td>Puppet, LDAP user management, Ebox</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/edubuntu-portal-server">Edubuntu Portal Server as a  Corporate Identity and Single Sign On solution</a></td>
<td>LDAP user management, user portal, CAS  authentication for external web applications</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/ldap-defaultdit-usergrp-mgmt">Default LDAP DIT for user and  group managment</a></td>
<td>Default LDAP directory structure</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/server-karmic-directory-architecture">Architecture of a directory  infrastructure</a></td>
<td>Directory structure, kerberos/SSO, indentity  management, authorization, access control, accounting, auditing</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/domain-for-linux">easy to install and use domain for  linux</a></td>
<td>LDAP server setup and management for users,  samba, nfs, mail, dhcp, dns, etc..</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/server-karmic-directory-management">Managing the directory</a></td>
<td>User management tools, FreeIPA</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/server-karmic-directory-service-configuration">Configuration of services to  integrate with a directory</a></td>
<td>Service configuration, kerberos principal  creation for clients, dns settings, service locating</td>
</tr>
<tr>
<td><a rel="nofollow" href="https://blueprints.launchpad.net/ubuntu/+spec/server-lucid-id-mgmt-reference-env">Identity management reference/test  config</a></td>
<td>Reference identity management environment  deployable with Puppet, using OpenLDAP/MIT Kerberos, <a rel="nofollow" href="https://launchpad.net/openldap-dit">openldap-dit</a></td>
</tr>
</tbody>
</table>
</div>
<p>Looking at the blueprints above it&#8217;s clear that Puppet is the tool of choice for configuration management. Based on my good experiences with Puppet I&#8217;m excited to see what comes out of it as more and more people start using it. For identity management there is no clear winner. There&#8217;s no common understanding about &#8220;standard&#8221; LDAP directory structure either. We have looked at many tools, but either they don&#8217;t support kerberos or they are all too technical. The end-user should not have to even know that there is LDAP in the background. Simplicity rules.</p>
<p>We have years old tools to manage our setups, but our goal is to make everything better integrated with Ubuntu/Edubuntu. Many of the tools need rewriting and we are now in the process looking at what has changed since the original tools were written years ago and put all our knowledge into improving the situation. The earlier blog entries about OpenLDAP are part of the process.</p>
<p>Our plan regarding user management tools for our environments looks something like this:</p>
<ol>
<li>Get a working set of scripts to setup OpenLDAP and MIT kerberos for  school usage (based on the earlier blog articles) &#8211; similar to what  openldap-dit does</li>
<li>Create a web based tool to manage LDAP/Kerberos users in easy  fashion</li>
<li>Solution for password synchronisation problem (userPassword in  LDAP, samba password and kerberos password should all be updated at  once)</li>
<li>Make LTSP servers and laptops authenticate against  OpenLDAP/Kerberos (pam-ldapd, nss-ldapd, <a href="../en/user-management-with-sssd-on-shared-laptops">sssd</a>)</li>
<li>Write LDAP/kerberos configuration instructions for  Moodle/Mediawiki/Zimbra/other common web applications used in schools</li>
<li>Create CAS/OpenID server with kerberos SSO support (Firefox can be  used to pass the kerberos ticket to the web server that turns it to web  login)</li>
</ol>
<p>We&#8217;ve been working on steps 1-3 already and we should be able to  release something working really soon now. It&#8217;s been a rough road at  times, but we are getting there.</p>
<p>There are still open questions like choice between Heimdal and MIT kerberos server. E.g. OpenLDAP has smbk5pwd overlay for Heimdal, but we are looking if a similar solution for MIT kerberos would be possible.</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/itch-for-better-user-management-in-ubuntu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User management with SSSD on shared laptops</title>
		<link>http://www.opinsys.fi/en/user-management-with-sssd-on-shared-laptops</link>
		<comments>http://www.opinsys.fi/en/user-management-with-sssd-on-shared-laptops#comments</comments>
		<pubDate>Fri, 26 Mar 2010 08:41:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[sssd]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[user management]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1157</guid>
		<description><![CDATA[A few months ago we had a blog entry about shared and personal laptops in schools. The goal of shared laptops is basically that they should behave mostly like shared thin clients: it should not matter which a computer any user chooses to work with. He should simply be able to pick any machine, login [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago we had a blog entry about <a href="http://www.opinsys.fi/en/en-laptops-in-schools"> shared and personal laptops in schools</a>.  The goal of shared laptops is basically that they should behave mostly like shared thin clients: it should not matter which a computer any user chooses to work with.  He should simply be able to pick any machine, login and get his own personal desktop environment, with his own documents and, for example, web browser bookmarks.</p>
<p>The problem of an accessible home directory could perhaps be solved satisfactorily with network filesystems such as NFSv4 or AFS, or alternatively with a synchronisation tool such as unison.  But even a more essential problem is user management.  How is it decided who may login into a laptop, and how is she authenticated and her user information (such as her name, but possibly other information) transmitted to the laptop?</p>
<p>With centralized directory services containing user information, such as NIS or LDAP, one way of solving the problem could be to replicate all data to laptops. We could run an LDAP slave server on every laptop, but that would not be very secure in case we stored the (hashed) password data in LDAP, because all the password hashes of all users would thus exists on every laptop.  The LDAP slave servers would also need a relatively unrestricted access to the master LDAP server, to synchronise their contents.  We have not tried to do this with laptops in Opinsys, and probably never will.</p>
<p>What we have previously done: we perform authentication on laptops against a web server through an SSL-protected http-connection.  The web server performs further authentication against Kerberos/LDAP.  In case this authentication is successful, the web server sends information about user&#8217;s name (and login), that is then used as a new user is created on the laptop.  The authentication token (a password) is stored on the laptop in a hashed format, permitting logins when a laptop is not connected to any network.</p>
<p>This means that any user who has a login and knows his password may pick a shared laptop and login, and in case the network is up and the services work, he may login later to the same laptop, even when the network is down.  But the way this is currently done is a kind of a hack: we do this with some PAM and Perl trickery, and we don&#8217;t support removing users, or changing their information, or including any information about their group memberships.  Kerberos tickets are not received on the laptop, even though they might be useful on some circumstances.  This scheme is not bad because it does work for most cases, but it could definitely be better.</p>
<h3>SSSD &mdash; a solution</h3>
<p>Enter <a href="http://fedoraproject.org/wiki/Features/SSSD"> System Security Services Daemon</a>, or SSSD for short.  This software is a Fedora subproject and is still quite new.  I do recommend exercising at least some caution when picking a new technology, especially when it provides some critical and security related functionality.  Thus, do not blindly try this without evaluating first whether or not SSSD really fits your needs.  But SSSD does seem to provide functionality which fits very well with the shared laptop concept.  Simply put, SSSD provides access to remote authentication servers and directories such as Kerberos and LDAP, and caches information so that it can be used when network is down.  It does need direct access to these services, but problems that exist in our current HTTPS/PAM/Perl-hack should be no more &mdash; as a whole it appears to provide what we need with a more clean design.</p>
<blockquote><p>
SSSD provides access to remote authentication servers and directories such as Kerberos and LDAP, and caches information so that it can be used when network is down.</p></blockquote>
<p>What follows are some simple instructions on settings up SSSD on Ubuntu, version 10.04 (Lucid Lynx).  Hopefully this will be of some use for people using other systems as well.  Currently, if you are using Kerberos, I recommend getting sssd packages from <a href="https://launchpad.net/~opinsys/+archive/ppa">our Launchpad repository</a> because of <a href="https://bugs.launchpad.net/ubuntu/+source/sssd/+bug/510290">this problem</a>.  The same problem is also referred to in <a href="http://blogs.fedoraproject.org/wp/sgallagh/2010/01/22/the-road-to-sssd-1-0-3/">this post</a> by an SSSD developer.  There is also another problem relating to Kerberos support in the Ubuntu repository package, which probably deserves a bug report&#8230;  If you do not use Kerberos, the current SSSD packages in Ubuntu repositories should be fine.</p>
<p>Next, we install the SSSD package:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo apt-get install sssd</pre>
</div>
<p>Configuration for SSSD is done in /etc/sssd/sssd.conf.  sssd.conf(5) manual page should tell you most of what you need about configuration parameters, but do check out at least sssd-krb5(5) and sssd-ldap(5) as well.  (Thankfully some people still write decent manual pages &mdash; the one true documentation format for unix systems.)  Here we set up an sss domain named KRBLDAP.EDU.EXAMPLE.ORG which uses Kerberos for authentication and LDAP for user information.  Edit &#8220;domains&#8221; line in /etc/sssd/sssd.conf:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
domains = KRBLDAP.EDU.EXAMPLE.ORG</pre>
</div>
<p>In the same file we should tell sssd what this domain actually means.  We make it use kerberos.edu.example.org as the Kerberos server, using EDU.EXAMPLE.ORG as the Kerberos realm, and ldap.edu.example.org as the ldap server.  Note that KRBLDAP.EDU.EXAMPLE.ORG is an arbitrary string and it does not need to be related in any way to the Kerberos realm, but for clarity this is perhaps a good naming scheme.  Setting up Kerberos and LDAP servers are beyond the scope of this blog posting. Do check out the meaning of the following options from the manual pages, and add this to /etc/sssd/sssd.conf:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[domain/KRBLDAP.EDU.EXAMPLE.ORG]
auth_provider = krb5
krb5_kdcip = kerberos.edu.example.org
krb5_realm = EDU.EXAMPLE.ORG
id_provider = ldap
ldap_uri = ldap://ldap.edu.example.org
ldap_search_base = dc=edu,dc=example,dc=org
ldap_tls_reqcert = demand
ldap_tls_cacert = /etc/ssl/certs/slapd-ca-cert.pem
cache_credentials = true
enumerate = true</pre>
</div>
<p>Restart sssd after editing the configuration:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo service sssd restart</pre>
</div>
<p>Now that we have sssd up and running, it is time to configure NSS and PAM to use it.  One way to achieve this is to use the auth-client-config package:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo apt-get install auth-client-config</pre>
</div>
<p>Write the following sss authentication profile into /etc/auth-client-config/profile.d/sss:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[sss]
nss_passwd=     passwd:         compat sss
nss_group=      group:          compat sss
nss_shadow=     shadow:         compat
nss_netgroup=   netgroup:       nis

pam_auth=       auth    [success=3 default=ignore]      pam_unix.so nullok_secure try_first_pass
                auth    requisite                       pam_succeed_if.so uid &gt;= 500 quiet
                auth    [success=1 default=ignore]      pam_sss.so use_first_pass
                auth    requisite                       pam_deny.so
                auth    required                        pam_permit.so

pam_account=    account required                                        pam_unix.so
                account sufficient                                      pam_localuser.so
                account sufficient                                      pam_succeed_if.so uid &lt; 500 quiet
                account [default=bad success=ok user_unknown=ignore]    pam_sss.so
                account required                                        pam_permit.so

pam_password=   password        sufficient      pam_unix.so obscure sha512
                password        sufficient      pam_sss.so use_authtok
                password        required        pam_deny.so

pam_session=    session required                        pam_mkhomedir.so skel=/etc/skel/ umask=0077
                session optional                        pam_keyinit.so revoke
                session required                        pam_limits.so
                session [success=1 default=ignore]      pam_sss.so
                session required                        pam_unix.so</pre>
</div>
<p>Note that editing NSS and PAM settings can be rather dangerous!  I suggest you keep a root shell open while doing this, and be ready to revert the changes in case something goes wrong.  Once you are properly prepared, do this:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo auth-client-config -n -a -p sss</pre>
</div>
<p>Nothing actually happened, which is okay, now read the auth-client-config(8) manual page on how to fix the above command to do some actual changes, and while at it also check out how to back out the changes with the same command, because you just might need that.</p>
<p>Now it should work.  Test it with getent, test it with su, try to login through gdm with users that are listed in LDAP.  Yet often we do not get it right the first time, which means it may be time to run sssd interactively with some debugging options on.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo service sssd stop
sudo sssd -i -d 4</pre>
</div>
<p>Here, the -d switch may take any value between 0 and 10 (inclusive) &mdash; this controls debug output level.  This allows you to see what sssd is doing as you login, or lookup a username, or whatever it is that you are doing that is somehow sssd related.</p>
<p>There is quite a bit more to sssd than this short introduction.  So far the version 1.0.2 seems pretty good &mdash; at least the project has some decent documentation and sssd problems are rather easy to debug, so perhaps also you might want to give it a try?</p>
<p>Juha Erkkilä</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/user-management-with-sssd-on-shared-laptops/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to use Cucumber with Ruby On Rails and ActiveLdap resources</title>
		<link>http://www.opinsys.fi/en/how-to-use-cucumber-with-ruby-on-rails-and-activeldap-resources</link>
		<comments>http://www.opinsys.fi/en/how-to-use-cucumber-with-ruby-on-rails-and-activeldap-resources#comments</comments>
		<pubDate>Fri, 19 Mar 2010 12:54:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[activeldap]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1118</guid>
		<description><![CDATA[I have accustomed to using Cucumber with Ruby on Rails for Behavior Driven Development when using sql database backends. What if data was stored within LDAP? I researched this point and it was very easy. I assume that you have installed Ubuntu 10.04 (Lucid) and have configured the OpenLDAP server with the following instructions (Server [...]]]></description>
			<content:encoded><![CDATA[<p>I have accustomed to using Cucumber with Ruby on Rails for Behavior Driven Development when using sql database backends. What if data was stored within LDAP? I researched this point and it was very easy.</p>
<p>I assume that you have installed Ubuntu 10.04 (Lucid) and have configured the OpenLDAP server with the following instructions (Server setup): <a rel="nofollow" href="http://www.opinsys.fi/setting-up-openldap-on-ubuntu-10-04-alpha2">Setting up OpenLDAP on Ubuntu 10.04 Alpha 2 (Lucid)</a></p>
<p>We have to add some access rules to slapd configurations so that ActiveLdap will work. This is not necessarily the right way to do this but with these simple changes we can make ActiveLdap work. Don&#8217;t do this to the production server if you don&#8217;t know what it means.</p>
<p>modify_acls.ldif:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>dn: olcDatabase={-1}frontend,cn=config
add: olcAccess
olcAccess: {1}to dn.base=cn=subschema by * read
olcAccess: {2}to dn.base= by * read</pre>
</pre>
</div>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo ldapmodify -Y EXTERNAL -H ldapi:<span style="color: #808080;background-color: inherit">/// -f modify_acls.ldif</span></pre>
</pre>
</div>
<p>Now we can start to make preparations for the new Rails project. In this example I use Ubuntu 10.04 Alpha 3 (Lucid)</p>
<p>Install the following packages from Ubuntu repositories:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo apt-get install ruby rubygems rake ruby-dev irb libxml2-dev libxslt-dev libopenssl-ruby</pre>
</pre>
</div>
<p>The following gems are needed:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo gem install rails cucumber-rails webrat activeldap ruby-net-ldap</pre>
</pre>
</div>
<p>Add the gem binaries to PATH:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>echo <span style="color: #009100;background-color: inherit">"PATH=\$PATH:/<span style="color: #000091;background-color: inherit">var</span>/lib/gems/1.8/bin"</span> &gt;&gt; ~/.bashrc</pre>
</pre>
</div>
<p>Create new rails project:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>rails user-management</pre>
</pre>
</div>
<p>As the next step, generate new REST resources with scaffold. This command also performs database migration. This is good because then we can verify that the Cucumber step passed correctly in the typical use case (using an sqlite database). We use the posixAccount objectClass (LDAP) attribute name. Thus we don't have to rename the attribute as we introduce ActiveLdap.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>./script/generate scaffold User cn:string uid:string uidNumber:integer gidNumber:integer \
homeDirectory:string</pre>
</pre>
</div>
<p>Create tables to the test database:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>RAILS_ENV=test rake db:migrate</pre>
</pre>
</div>
<p>Cucumber initialization:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>./script/generate cucumber
echo <span style="color: #009100;background-color: inherit">"<span style="color: #000091;background-color: inherit">default</span>: --format pretty features"</span> &gt;&gt; cucumber.yml</pre>
</pre>
</div>
<p>Generate User feature:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>./script/generate feature User cn:string uid:string uidNumber:integer gidNumber:integer \
homeDirectory:string</pre>
</pre>
</div>
<p>Edit manage_users.feature file and replace the following content:</p>
<p>features/manage_users.feature:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>Feature: Manage users
  In order to manage authorization
  User
  wants to add, remove, and organize users

  Scenario: Add <span style="color: #000091;background-color: inherit">new</span> user
    Given I am on the <span style="color: #000091;background-color: inherit">new</span> user page
    When I fill in <span style="color: #009100;background-color: inherit">"Cn"</span> with <span style="color: #009100;background-color: inherit">"Joe Taylor"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Uid"</span> with <span style="color: #009100;background-color: inherit">"joe"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Uidnumber"</span> with <span style="color: #009100;background-color: inherit">"11001"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Gidnumber"</span> with <span style="color: #009100;background-color: inherit">"11001"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Homedirectory"</span> with <span style="color: #009100;background-color: inherit">"/home/joe"</span>
    And I press <span style="color: #009100;background-color: inherit">"Create"</span>
    Then I should see <span style="color: #009100;background-color: inherit">"Joe Taylor"</span>
    And I should see <span style="color: #009100;background-color: inherit">"joe"</span>
    And I should see <span style="color: #009100;background-color: inherit">"11001"</span>
    And I should see <span style="color: #009100;background-color: inherit">"11001"</span>
    And I should see <span style="color: #009100;background-color: inherit">"/home/joe"</span></pre>
</pre>
</div>
<p>Now you can run Cucumber</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>cucumber</pre>
</pre>
</div>
<p>..and the result should be one passed scenario.</p>
<p>Now we have User resource and we can test that it works. Data was stored in the sqlite database and in the next step we switch to ActiveLdap and LDAP storage.</p>
<p>Add following line to config/environment.rb:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>config.gem 'activeldap', :lib =&gt; 'active_ldap'</pre>
</pre>
</div>
<p>Initialize ActiveLdap:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>./script/generate scaffold_active_ldap</pre>
</pre>
</div>
<p>Edit config/ldap.yml file and add the following content:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>cucumber:
  host: localhost
  base: dc=edu,dc=example,dc=org
  bind_dn: uid=admin,ou=People,dc=edu,dc=example,dc=org
  password: example</pre>
</pre>
</div>
<p>Modify app/models/user.rb file and replace it with the following content:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>class User &lt; ActiveLdap::Base
  ldap_mapping( :dn_attribute =&gt; <span style="color: #009100;background-color: inherit">"uid"</span>,
                :prefix =&gt; <span style="color: #009100;background-color: inherit">"ou=People"</span>,
                :classes =&gt; ['top', 'posixAccount', 'account'] )
end</pre>
</pre>
</div>
<p>OpenLDAP does not support a transaction system such as in a typical SQL-database. This is why we need use Before hook. First we have to clear the data so that the test scenario works correctly.</p>
<p>Edit features/step_definitions/user_steps.rb file and add following content:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>Before <span style="color: #000091;background-color: inherit">do</span> |scenario|
  User.all.each <span style="color: #000091;background-color: inherit">do</span> |u|
    u.destroy
  end
end</pre>
</pre>
</div>
<p>It should now work. Run cucumber command:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>cucumber</pre>
</pre>
</div>
<p>..and the result should be one passed scenario.</p>
<p>Add the following LDAP specific scenario. Edit features/manage_users.feature file and add the following content:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>  Scenario: Add dupplicate distinguishedName
    Given the following users:
    | cn         | Uid | Uidnumber | Gidnumber | Homedirectory |
    | Joe Taylor | joe |     11001 |     11001 | /home/joe     |
    And I am on the <span style="color: #000091;background-color: inherit">new</span> user page
    When I fill in <span style="color: #009100;background-color: inherit">"Cn"</span> with <span style="color: #009100;background-color: inherit">"Joe Wilson"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Uid"</span> with <span style="color: #009100;background-color: inherit">"joe"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Uidnumber"</span> with <span style="color: #009100;background-color: inherit">"11002"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Gidnumber"</span> with <span style="color: #009100;background-color: inherit">"11001"</span>
    And I fill in <span style="color: #009100;background-color: inherit">"Homedirectory"</span> with <span style="color: #009100;background-color: inherit">"/home/joew"</span>
    And I press <span style="color: #009100;background-color: inherit">"Create"</span>
    Then I should see <span style="color: #009100;background-color: inherit">"distinguishedName is duplicated"</span>
    When I fill in <span style="color: #009100;background-color: inherit">"Uid"</span> with <span style="color: #009100;background-color: inherit">"joew"</span>
    And I press <span style="color: #009100;background-color: inherit">"Create"</span>
    Then I should see <span style="color: #009100;background-color: inherit">"Joe Wilson"</span>
    And I should see <span style="color: #009100;background-color: inherit">"joew"</span>
    And I should see <span style="color: #009100;background-color: inherit">"11002"</span>
    And I should see <span style="color: #009100;background-color: inherit">"11001"</span>
    And I should see <span style="color: #009100;background-color: inherit">"/home/joew"</span></pre>
</pre>
</div>
<p>DN duplicates are not allowed on the LDAP-server. This scenario ensures that the LDAP-server behaves like this.</p>
<p>Run cucumber command.</p>
<p>Result should be following:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>2 scenarios (2 passed)
27 steps (27 passed)</pre>
</pre>
</div>
<p>Jouni Korhonen</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/how-to-use-cucumber-with-ruby-on-rails-and-activeldap-resources/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>OpenLDAP authentication with kerberos backend using SASL</title>
		<link>http://www.opinsys.fi/en/openldap-authentication-with-kerberos-backend-using-sasl</link>
		<comments>http://www.opinsys.fi/en/openldap-authentication-with-kerberos-backend-using-sasl#comments</comments>
		<pubDate>Tue, 16 Mar 2010 15:07:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[OpenLDAP]]></category>
		<category><![CDATA[sasl]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1101</guid>
		<description><![CDATA[<!--:fi-->Now that MIT Kerberos is running using OpenLDAP as storage backend, the next logical step is to make OpenLDAP use MIT Kerberos as its password backend.<!--:--><!--:se-->Now that MIT Kerberos is running using OpenLDAP as storage backend, the next logical step is to make OpenLDAP use MIT Kerberos as its password backend.<!--:--><!--:en-->Now that MIT Kerberos is running using OpenLDAP as storage backend, the next logical step is to make OpenLDAP use MIT Kerberos as its password backend.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going through quite a few OpenLDAP configuration steps already, but there are still new setup possibilities to try. I&#8217;m not sure if I&#8217;m always too curious or if it&#8217;s just the new Ubuntu Lucid that is making me try how these things are working with it.</p>
<p>Now that MIT Kerberos is running using OpenLDAP as storage backend, the next logical step is to make OpenLDAP use MIT Kerberos as its password backend. If one needs both kerberos ja ldap bind authentication working, it&#8217;s really easy to get some of those passwords out of sync. Users are usually not happy if they suddenly start having randomly different passwords for different services when they change their password. Until now I&#8217;ve been using tools that always update the different passwords (userPassword in ldap, ntml hash for samba and kerberos) at the same time, but sometimes there have been problems making sure that all actually changed.</p>
<p>To make syncing possible, I&#8217;ll be going through the steps to get OpenLDAP to forward the ldap binds to SASL which in turn forwards them to Kerberos using GSSAPI. This solution works when there is need to support ldap binds for applications that don&#8217;t support kerberos directly. This shouldn&#8217;t be mistaken for real kerberos authentication as this solution still needs the user password to be sent to OpenLDAP over the wire.</p>
<p>The following documents tell more background information and were used to do the configuration described in this posting:</p>
<ul>
<li><a rel="nofollow" href="http://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer">Wikipedia on SASL</a></li>
<li><a rel="nofollow" href="http://tools.ietf.org/html/rfc4422">RFC #4422 &#8211; Simple Authentication and Security Layer (SASL)</a></li>
<li><a rel="nofollow" href="http://www.openldap.org/doc/admin24/security.html#Pass-Through%20authentication">OpenLDAP&#8217;s Pass-Through authentication</a></li>
</ul>
<p>Simple Authentication and Security Layer (SASL) is one of the mysterious acronyms that pop up once in a while, but often one really cannot figure out what it does. SASL makes it possible to authenticate connection based protocols with any authentication method that the server and client both support. This means that the protocol itself does not need to define all the authentication methods that can be used.</p>
<p>What I&#8217;ll be using here is OpenLDAP&#8217;s pass-through authentication that replaces the user&#8217;s password with instructions to use SASL, e.g.:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>userPassword: {SASL}username@REALM</pre>
</div>
<p>This tells OpenLDAP that that password is not local, but instead SASL authentication should be made with <em>username@REALM</em>. On Debian/Ubuntu usually the Cyrus-SASL implementation is used. More information about the Pass-Through authentication is available in the OpenLDAP manual.</p>
<p>To get started with the setup you should have working OpenLDAP + MIT kerberos setup as described in the earlier postings. On top of these the following packages are needed on the machine running OpenLDAP server:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo apt-get install sasl2-bin libsasl2-modules-gssapi-mit</pre>
</div>
<p>To configure saslauthd I used the following settings. From the Ubuntu Lucid defaults I had to change START and MECHANISMS lines.<br />
<strong>/etc/default/saslauthd</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>START=yes
DESC=<span>"SASL Authentication Daemon"</span>
NAME=<span>"saslauthd"</span>
MECHANISMS=<span>"kerberos5"</span>
MECH_OPTIONS=""
THREADS=5
OPTIONS=<span>"-c -m /<span>var</span>/run/saslauthd"</span></pre>
</div>
<p>The default installation gives only sasl group access to the socket directory:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>user@server:~$ ls -ld /var/run/saslauthd
drwx--x--- 2 root sasl 140 2010-03-04 09:47 /var/run/saslauthd</pre>
</div>
<p>Adding the openldap user to the sasl group gives it access to the socket:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo adduser openldap sasl</pre>
</div>
<p>To get make sure that SASL is installed correctly, run the following command to test the authentication:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>testsaslauthd -u user@EDU.EXAMPLE.ORG -p userpassword</pre>
</div>
<p>If everything works, you should see something like this:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>0: OK <span>"Success."</span></pre>
</div>
<p>If something went wrong the answer is something like this:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>0: NO <span>"authentication failed"</span></pre>
</div>
<p>Next test that slapd authentication works:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>ldapsearch -D uid=user,ou=people,dc=edu,dc=example,dc=org -W -b dc=edu,dc=example,dc=org</pre>
</div>
<p>The search should return results normally and authentication should happen against the kerberos server. If authentication doesn&#8217;t work, check the /var/log/kdc.log (on debian/ubuntu) and try running saslauthd from command line in debug mode:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo /usr/sbin/saslauthd -a kerberos5 -m /var/run/saslauthd -d</pre>
</div>
<p>Now I&#8217;m just left with the problem of having the ntml hashed password for samba in the ldap directory, but at least there&#8217;s one less password to manage. Any ideas for the next step?</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/openldap-authentication-with-kerberos-backend-using-sasl/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up NFSv4+Kerberos+Autofs5-ldap on Ubuntu 10.04 Alpha 2 (Lucid), part 7</title>
		<link>http://www.opinsys.fi/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7</link>
		<comments>http://www.opinsys.fi/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7#comments</comments>
		<pubDate>Mon, 22 Feb 2010 12:32:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[autofs]]></category>
		<category><![CDATA[autofs5]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[nfs4]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1065</guid>
		<description><![CDATA[<!--:fi-->After getting NFSv4 working, it'd be of course nice to automatically mount the nfs exported home directories. In this part I'm going through the steps to get school specific home directories mounted from a central server. Using autofs is an alternative to defining the mounted directories in /etc/fstab. It mounts the directories automatically when they are needed instead of doing it at boot time.<!--:--><!--:se-->After getting NFSv4 working, it'd be of course nice to automatically mount the nfs exported home directories. In this part I'm going through the steps to get school specific home directories mounted from a central server. Using autofs is an alternative to defining the mounted directories in /etc/fstab. It mounts the directories automatically when they are needed instead of doing it at boot time.<!--:--><!--:en-->After getting NFSv4 working, it'd be of course nice to automatically mount the nfs exported home directories. In this part I'm going through the steps to get school specific home directories mounted from a central server. Using autofs is an alternative to defining the mounted directories in /etc/fstab. It mounts the directories automatically when they are needed instead of doing it at boot time.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>This blog posting is a part of a series of blog postings:</p>
<ul>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha2">Part 1 &#8211; OpenLDAP setup</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-lucid-part2">Part 2 &#8211; SSL/TLS</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3">Part 3 &#8211; Schemas for samba, autofs and kerberos</a></li>
<li><a href="/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid">Part 4 &#8211; Kerberos setup</a></li>
<li><a href="/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings">Part 5 &#8211; DNS settings for kerberos using dnsmasq</a></li>
<li><a href="/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6">Part 6 &#8211; NFSv4 with kerberos</a></li>
<li><a hreF="/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7">Part 7 &#8211; Autofs</a></li>
</ul>
<p>After getting NFSv4 working, it&#8217;d be of course nice to automatically mount the nfs exported home directories. In this part I&#8217;m going through the steps to get school specific home directories mounted from a central server. Using autofs is an alternative to defining the mounted directories in /etc/fstab. It mounts the directories automatically when they are needed instead of doing it at boot time. This especially handy in situations where some servers are not immediately available after boot because of network issues. Also the number of mounts is kept down when not needed, which has helped with server stability issues. Autofs mountpoints can be configured either statically for every client or centrally in ldap. Ldap configuration allows one to easily add new mountpoints without modifying every client separately.</p>
<p>In this setup there&#8217;s a single file server that has a separate subdirectory under /home for every school. The directories are:</p>
<ul>
<li>server:/home/school1</li>
<li>server:/home/school2</li>
<li>server:/home/school3</li>
</ul>
<p>The autofs.schema was installed in part 3 of this series. In addition to autofs-ldap package, also some entries are needed in ldap. First the basic data that autofs uses to recognize that it is configured:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>#!/bin/sh

ldapadd -D uid=admin,ou=People,dc=edu,dc=example,dc=org -x -W &lt;&lt; EOF
dn: ou=Automount,dc=edu,dc=example,dc=org
ou: Automount
objectClass: top
objectClass: organizationalUnit

dn: ou=auto.master,ou=Automount,dc=edu,dc=example,dc=org
ou: auto.master
objectClass: top
objectClass: automountMap
EOF</pre>
</div>
<p>We want to use autofs to mount directories under /home, so it needs to be defined:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>#!/bin/sh

ldapadd -D uid=admin,ou=People,dc=edu,dc=example,dc=org -x -W &lt;&lt; EOF
dn: cn=/home,ou=auto.master,ou=Automount,dc=edu,dc=example,dc=org
cn: /home
objectClass: top
objectClass: automount
automountInformation: ldap:ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org rsize=8192,wsize=8192
EOF</pre>
</div>
<p>This tells autofs to look for individual directories under the suffix ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org. The directories are then defined under the defined suffix:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>#!/bin/sh

ldapadd -D uid=admin,ou=People,dc=edu,dc=example,dc=org -x -W &lt;&lt; EOF
dn: ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org
ou: auto.home
objectClass: top
objectClass: automountMap

dn: cn=school1,ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org
cn: school1
objectClass: top
objectClass: automount
automountInformation: -fstype=nfs4,rw,sec=krb5 server.edu.example.org:/home/school1

dn: cn=school2,ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org
cn: school2
objectClass: top
objectClass: automount
automountInformation: -fstype=nfs4,rw,sec=krb5 server.edu.example.org:/home/school2

dn: cn=school3,ou=auto.home,ou=Automount,dc=edu,dc=example,dc=org
cn: school3
objectClass: top
objectClass: automount
automountInformation: -fstype=nfs4,rw,sec=krb5 server.edu.example.org:/home/school3
EOF</pre>
</div>
<p>Now the server side should be rocking and the clients need to be instructed to look for mountpoints in ldap. First autofs needs to be installed on the client machine:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo apt-get install autofs5-ldap ldap-utils</pre>
</div>
<p>And the following settings instructs autofs to use ldap as data storage and where in the ldap tree the information is stored:</p>
<p><strong>/etc/nsswitch.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>  automount: ldap</pre>
</div>
<p><strong>/etc/default/autofs</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>TIMEOUT=60
LDAP_URI=ldap://ldap.edu.example.org/
SEARCH_BASE="ou=auto.master,ou=Automount,dc=edu,dc=example,dc=org"

MAP_OBJECT_CLASS="automountMap"
ENTRY_OBJECT_CLASS="automount"
MAP_ATTRIBUTE="ou"
ENTRY_ATTRIBUTE="cn"
VALUE_ATTRIBUTE="automountInformation"</pre>
</div>
<p>Next restart /etc/init.d/autofs and /home/school{1|2|3} should mount automatically.</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up NFSv4+Kerberos on Ubuntu 10.04 Alpha 2 (Lucid), part 6</title>
		<link>http://www.opinsys.fi/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6</link>
		<comments>http://www.opinsys.fi/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6#comments</comments>
		<pubDate>Sun, 21 Feb 2010 17:09:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[nfs4]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1052</guid>
		<description><![CDATA[<!--:fi-->Next it's time to finally get files moving between the servers. For this we use NFSv4 that supports kerberos out-of-the-box also in Ubuntu. This part is based on the newest Lucid packages in the repositories, which should be pretty close to alpha 3 now.<!--:--><!--:se-->Next it's time to finally get files moving between the servers. For this we use NFSv4 that supports kerberos out-of-the-box also in Ubuntu. This part is based on the newest Lucid packages in the repositories, which should be pretty close to alpha 3 now.<!--:--><!--:en-->Next it's time to finally get files moving between the servers. For this we use NFSv4 that supports kerberos out-of-the-box also in Ubuntu. This part is based on the newest Lucid packages in the repositories, which should be pretty close to alpha 3 now.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>This blog posting is a part of a series of blog postings:</p>
<ul>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha2">Part 1 &#8211; OpenLDAP setup</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-lucid-part2">Part 2 &#8211; SSL/TLS</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3">Part 3 &#8211; Schemas for samba, autofs and kerberos</a></li>
<li><a href="/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid">Part 4 &#8211; Kerberos setup</a></li>
<li><a href="/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings">Part 5 &#8211; DNS settings for kerberos using dnsmasq</a></li>
<li><a href="/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6">Part 6 &#8211; NFSv4 with kerberos</a></li>
<li><a hreF="/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7">Part 7 &#8211; Autofs</a></li>
</ul>
<p>Next it&#8217;s time to finally get files moving between the servers. For this we use NFSv4 that supports kerberos out-of-the-box also in Ubuntu. This part is based on the newest Lucid packages in the repositories, which should be pretty close to alpha 3 now.</p>
<p>The following documents were used to get the configuration working:</p>
<ul>
<li><a rel="nofollow" href="https://help.ubuntu.com/community/NFSv4Howto">https://help.ubuntu.com/community/NFSv4Howto</a></li>
<li><a rel="nofollow" href="http://mit.edu/kerberos/krb5-1.5/krb5-1.5.4/doc/krb5-admin/Hostnames-for-KDCs.html#Hostnames-for-KDCs">MIT Kerberos manual: Hostnames for KDCs</a></li>
<li><a rel="nofollow" href="http://www-theorie.physik.unizh.ch/%7Edpotter/howto/kerberos">Doug Potter: Kerberos/LDAP/NFSv4 HOWTO</a></li>
</ul>
<p>The goal of the setup is to have a single file server that shares the following directories to clients over NFSv4 with kerberos authentication:</p>
<ul>
<li>/home/school1</li>
<li>/home/school2</li>
<li>/home/school3</li>
</ul>
<p>The server will not allow root to access other users&#8217; files which makes it possible to export the shares in potentially hostile environments as the compromise of a single client host does not expose all contents of the file server.</p>
<h2>Server settings</h2>
<p>The following packages are needed on the server:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>apt-get install nfs-kernel-server nfs-common</pre>
</div>
<p>Unlike NFSv3, NFSv4 uses a separate directory structure to share the directories. The actual content is mounted with mount &#8211;bind under this directory. Here we place the directories under /export:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo mkdir /export
sudo mkdir /export/home</pre>
</div>
<p>Then we instruct in /etc/fstab that /home should be mounted under /export/home. The following should be added in bottom of /etc/fstab:</p>
<p><strong>/etc/fstab</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>/home    /export/home   none    bind  0  0</pre>
</div>
<p>After this /export/home can be mounted with the following command and it is also automatically mounted when the system boots:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo mount /export/home</pre>
</div>
<p>Next configure the exports in /etc/exports to be exported to all nfs4 clients using kerberos:</p>
<p><strong>/etc/exports</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>/export         gss/krb5(rw,fsid=0,async,subtree_check,no_root_squash,crossmnt)
/export/home    gss/krb5(rw,async,subtree_check,no_root_squash)
/export/home/school1	gss/krb5(rw,async,subtree_check,root_squash,crossmnt)
/export/home/school2	gss/krb5(rw,async,subtree_check,root_squash,crossmnt)
/export/home/school3	gss/krb5(rw,async,subtree_check,root_squash,crossmnt)</pre>
</div>
<p>Next configure NFS to use kerberos:</p>
<p><strong>/etc/default/nfs-common</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>NEED_STATD=
STATDOPTS=
NEED_IDMAPD=yes
NEED_GSSD=yes</pre>
</div>
<p><strong>/etc/default/nfs-kernel-server</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>RPCNFSDCOUNT=10
RPCNFSDPRIORITY=0
RPCMOUNTDOPTS=
NEED_SVCGSSD=yes
RPCSVCGSSDOPTS=</pre>
</div>
<p>idmapd.conf needs to configured with proper Domain name for user/group name mappings:<br />
<strong>/etc/idmapd.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>[General]

Verbosity = 0
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = EDU.EXAMPLE.ORG

[Mapping]

Nobody-User = nobody
Nobody-Group = nogroup</pre>
</div>
<p>The NFS server version in Lucid supports only DES encryption which is not enabled by default. There is more information available in the bug reports:</p>
<ul>
<li><a rel="nofollow" href="https://bugs.launchpad.net/ubuntu/+source/krb5/+bug/512110">Bug report in Launchpad</a></li>
<li><a rel="nofollow" href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521878">Bug report in Debian bug tracker</a></li>
</ul>
<p>For now DES can be enabled with the following settings:<br />
<strong>/etc/krb5.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>[libdefaults]
  allow_weak_crypto = <span>true</span>
  default_tgs_enctypes = des-cbc-crc
  default_tkt_enctypes = des-cbc-crc</pre>
</div>
<p>Next we need to create kerberos principals for the server and the clients. In this example all the principals are created on the server and copied to the clients. It is also possible to use kadmin remotely from the client machines.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo kadmin.local -q "addprinc -randkey nfs/server.edu.example.org"
sudo kadmin.local -q "ktadd -e des-cbc-crc:normal nfs/server.edu.example.org"

sudo kadmin.local -q "addprinc -randkey nfs/client1.edu.example.org"
sudo kadmin.local -q "ktadd -e des-cbc-crc:normal -k client1.keytab nfs/client1.edu.example.org"

sudo kadmin.local -q "addprinc -randkey nfs/client2.edu.example.org"
sudo kadmin.local -q "ktadd -e des-cbc-crc:normal -k client2.keytab nfs/client2.edu.example.org"</pre>
</div>
<p>Now copy the client1.keytab and client2.keytab to /etc/krb5.keytab on the client machines and make them only readable by root.</p>
<p>The server should now be ready after restarting the services:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo service gssd start
sudo service rpc_pipefs start
sudo /usr/sbin/rpc.gssd
sudo service idmapd start

sudo /etc/init.d/nfs-kernel-server restart</pre>
</div>
<p>The server functionality can be tested by trying to mount one of the exported shares locally:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo mount -t nfs4 -o sec=krb5 server.edu.example.org:/home/school1 /mnt</pre>
</div>
<h2>Client settings</h2>
<p>The following packages are needed on the client machines:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>apt-get install nfs-common krb5-user</pre>
</div>
<p>To avoid having to configure the kerberos server settings on each client separately, one can use DNS to store the settings as described in the previous posting.</p>
<p><strong>/etc/krb5.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>[libdefaults]
  default_realm = EDU.EXAMPLE.ORG
  allow_weak_crypto = <span>true</span>
  default_tgs_enctypes = des-cbc-crc
  default_tkt_enctypes = des-cbc-crc
  dns_lookup_kdc = <span>true</span>
  dns_lookup_realm = <span>true</span></pre>
</div>
<p><strong>/etc/default/nfs-common</strong> &#8211; idmapd and gssd need to be enabled</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>NEED_STATD=
STATDOPTS=
NEED_IDMAPD=yes
NEED_GSSD=yes
RPCGSSDOPTS="-vvv -rrr"  # <span>for</span> debugging</pre>
</div>
<p><strong>/etc/idmapd.conf</strong> &#8211; Domain must match the name defined on the server for user and group name mapping to work</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>[General]

Verbosity = 0
Pipefs-Directory = /<span>var</span>/lib/nfs/rpc_pipefs
Domain = EDU.EXAMPLE.ORG

[Mapping]

Nobody-User = nobody
Nobody-Group = nogroup</pre>
</div>
<p>After configuration nfs-common needs to be restarted (modules need to be loaded if they haven&#8217;t been loaded automatically):</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo modprobe nfs
sudo modprobe rpcsec_gss_krb5

sudo service idmapd start
sudo service gssd start
sudo service portmap restart</pre>
</div>
<p>Mounting the share should now work with mount command:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo mount -t nfs4 -o sec=krb5 server.edu.example.org:/home/school1 /home/school1</pre>
</div>
<p>If there are problems, restarting the client machine may help as sometimes picking up the kerberos setting hasn&#8217;t worked for me. I&#8217;m probably missing some service that requires restarting..</p>
<p>At this point we have no kerberos ticket, so the user should not be able to enter his own home directory:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>user$ cd /home/school1/user
-bash: cd: /home/school1/user: Permission denied</pre>
</div>
<p>After getting the ticket it should work:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>user$ kinit user@EDU.EXAMPLE.ORG
Password for user@EDU.EXAMPLE.ORG:
user$ cd /home/school1/user</pre>
</div>
<p>Root squash should also prevent root from entering directories for other users on the client machine:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>user$ cd /home/school1/otheruser
-bash: cd: /home/school1/otheruser: Permission denied

# cd /home/school1/otheruser
-bash: cd: /home/school1/otheruser: Permission denied</pre>
</div>
<p>Now give it a reboot and try again. Everything should be now working.</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up OpenLDAP+Kerberos on Ubuntu 10.04 Alpha 2 (Lucid), part 5 &#8211; DNS settings</title>
		<link>http://www.opinsys.fi/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings</link>
		<comments>http://www.opinsys.fi/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings#comments</comments>
		<pubDate>Fri, 19 Feb 2010 11:51:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[dnsmasq]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[OpenLDAP]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=1041</guid>
		<description><![CDATA[<!--:fi-->Kerberos requires every client to know where the server is located. This can be done either by using /etc/krb5.conf file or using DNS to distribute the information. Using DNS makes it easier to do changes in the network settings as not every client needs to be updated. Next we aim to minimize the amount of configuration needed for every client so configuring DNS properly is a logical first step.<!--:--><!--:se-->Kerberos requires every client to know where the server is located. This can be done either by using /etc/krb5.conf file or using DNS to distribute the information. Using DNS makes it easier to do changes in the network settings as not every client needs to be updated. Next we aim to minimize the amount of configuration needed for every client so configuring DNS properly is a logical first step.<!--:--><!--:en-->Kerberos requires every client to know where the server is located. This can be done either by using /etc/krb5.conf file or using DNS to distribute the information. Using DNS makes it easier to do changes in the network settings as not every client needs to be updated. Next we aim to minimize the amount of configuration needed for every client so configuring DNS properly is a logical first step.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>This blog posting is a part of a series of blog postings:</p>
<ul>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha2">Part 1 &#8211; OpenLDAP setup</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-lucid-part2">Part 2 &#8211; SSL/TLS</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3">Part 3 &#8211; Schemas for samba, autofs and kerberos</a></li>
<li><a href="/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid">Part 4 &#8211; Kerberos setup</a></li>
<li><a href="/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings">Part 5 &#8211; DNS settings for kerberos using dnsmasq</a></li>
<li><a href="/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6">Part 6 &#8211; NFSv4 with kerberos</a></li>
<li><a hreF="/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7">Part 7 &#8211; Autofs</a></li>
</ul>
<p>Kerberos requires every client to know where the server is located. This can be done either by using /etc/krb5.conf file or using DNS to distribute the information. Using DNS makes it easier to do changes in the network settings as not every client needs to be updated. Next we aim to minimize the amount of configuration needed for every client so configuring DNS properly is a logical first step.</p>
<p>The following documents were used to get the configuration working:</p>
<ul>
<li><a rel="nofollow" href="https://help.ubuntu.com/community/NFSv4Howto">https://help.ubuntu.com/community/NFSv4Howto</a></li>
<li><a rel="nofollow" href="http://mit.edu/kerberos/krb5-1.5/krb5-1.5.4/doc/krb5-admin/Hostnames-for-KDCs.html#Hostnames-for-KDCs">MIT Kerberos manual: Hostnames for KDCs</a></li>
<li><a rel="nofollow" href="http://www-theorie.physik.unizh.ch/%7Edpotter/howto/kerberos">Doug Potter: Kerberos/LDAP/NFSv4 HOWTO</a></li>
</ul>
<p>The goal of the setup is to have a single file server that shares the following directories to clients over NFSv4 with kerberos authentication:</p>
<ul>
<li>/home/school1</li>
<li>/home/school2</li>
<li>/home/school3</li>
</ul>
<p>The server will not allow root to access other users&#8217; files which makes it possible to export the shares in potentially hostile environments as the compromise of a single client host does not expose all contents of the file server.</p>
<p>The domain name used is edu.example.org and the NFS server will be the same machine as the kerberos server. The names used in this example map to following IPs:</p>
<ul>
<li>server.edu.example.org &#8211; 10.0.0.1</li>
<li>ldap.edu.example.org &#8211; 10.0.0.1</li>
<li>kerberos.edu.example.org &#8211; 10.0.0.1</li>
<li>client1.edu.example.org &#8211; 10.0.0.10</li>
<li>client2.edu.example.org &#8211; 10.0.0.11</li>
</ul>
<h3>DNS settings</h3>
<p>Before we start with the NFS setup, we need to make sure that name resolution for the server and clients works with fully qualified domain names (fqdn). Also reverse mappings need to be working for NFSv4+krb5 to work properly.</p>
<p>There are many DNS servers that can be used. Here we use dnsmasq:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>sudo apt-get install dnsmasq</pre>
</div>
<p><strong>/etc/dnsmasq.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>domain-needed
domain=edu.example.org

ptr-record=1.0.0.10.in-addr.arpa.,<span>"server.edu.example.org"</span>
address=/server.edu.example.org/10.0.0.1

ptr-record=10.0.0.10.in-addr.arpa.,<span>"client1.edu.example.org"</span>
address=/client1.edu.example.org/10.0.0.10

ptr-record=11.0.0.10.in-addr.arpa.,<span>"client2.edu.example.org"</span>
address=/client2.edu.example.org/10.0.0.11</pre>
</div>
<p>After restarting dnsmasq and configuring it to be used in /etc/resolv.conf, it should resolve names properly both ways:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>$ nslookup server.edu.example.org

Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	server.edu.example.org
Address: 10.0.0.1

$ nslookup 10.0.0.1

Server:		127.0.0.1
Address:	127.0.0.1#53

1.0.0.10.in-addr.arpa	name = server.edu.example.org.</pre>
</div>
<p>Make sure that also the client machine names resolve correctly.</p>
<p>In addition to having DNS server configured properly, if the /etc/hosts file has names configured, make sure that the FQDN is before the shortname, e.g.:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>10.0.0.1 server.edu.example.org server
10.0.0.10 client1.edu.example.org client1
10.0.0.11 client2.edu.example.org client2</pre>
</div>
<p>This makes sure that host mappings are not done from /etc/hosts using the shortname of the server.</p>
<p>While we are at it, let&#8217;s also add the SRV records for kerberos so that we don&#8217;t need to configure kerberos realms for every client separately:</p>
<p><strong>/etc/dnsmasq.conf</strong></p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>address=/kerberos.edu.example.org/10.0.0.1
address=/ldap.edu.example.org/10.0.0.1

txt-record=_kerberos.edu.example.org,"EDU.EXAMPLE.ORG"
srv-host=_kerberos._udp.edu.example.org,"kerberos.edu.example.org",88
srv-host=_kerberos._tcp.edu.example.org,"kerberos.edu.example.org",88
srv-host=_kerberos-master._udp.edu.example.org,kerberos."edu.example.org",88
srv-host=_kerberos-adm._tcp.edu.example.org,"kerberos.edu.example.org",749
srv-host=_kpasswd._udp.edu.example.org,"kerberos.edu.example.org",464</pre>
</div>
<p>Clients can now find the kerberos server automatically when the realm is given (e.g. kinit testuser@EDU.EXAMPLE.ORG). To set default realm, /etc/krb5.conf can be used:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[libdefaults]
        default_realm = EDU.EXAMPLE.ORG
	dns_lookup_kdc = true
	dns_lookup_realm = true</pre>
</div>
<p>Now the name server should be ready for the actual setup. The actual NFSv4+kerberos setup is described in the next part.</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up OpenLDAP+Kerberos on Ubuntu 10.04 Alpha 2 (Lucid), part 4</title>
		<link>http://www.opinsys.fi/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid</link>
		<comments>http://www.opinsys.fi/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid#comments</comments>
		<pubDate>Fri, 05 Feb 2010 11:25:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=871</guid>
		<description><![CDATA[<!--:fi-->After getting OpenLDAP running properly and the schemas in place, the next step is to get Kerberos and AutoFS running on top of it to enable centrally managed automatic NFSv4+kerberos mounts to user home directories. Here we setup kerberos using OpenLDAP as the backend to store the principals. This allows one to easily replicate the data to slave servers.<!--:--><!--:se-->After getting OpenLDAP running properly and the schemas in place, the next step is to get Kerberos and AutoFS running on top of it to enable centrally managed automatic NFSv4+kerberos mounts to user home directories. Here we setup kerberos using OpenLDAP as the backend to store the principals. This allows one to easily replicate the data to slave servers.<!--:--><!--:en-->After getting OpenLDAP running properly and the schemas in place, the next step is to get Kerberos and AutoFS running on top of it to enable centrally managed automatic NFSv4+kerberos mounts to user home directories. Here we setup kerberos using OpenLDAP as the backend to store the principals. This allows one to easily replicate the data to slave servers.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>This blog posting is a part of a series of blog postings:</p>
<ul>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha2">Part 1 &#8211; OpenLDAP setup</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-lucid-part2">Part 2 &#8211; SSL/TLS</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3">Part 3 &#8211; Schemas for samba, autofs and kerberos</a></li>
<li><a href="/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid">Part 4 &#8211; Kerberos setup</a></li>
<li><a href="/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings">Part 5 &#8211; DNS settings for kerberos using dnsmasq</a></li>
<li><a href="/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6">Part 6 &#8211; NFSv4 with kerberos</a></li>
<li><a hreF="/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7">Part 7 &#8211; Autofs</a></li>
</ul>
<p>After getting OpenLDAP running properly and the schemas in place, the next step is to get Kerberos and AutoFS running on top of it to enable centrally managed automatic NFSv4+kerberos mounts to user home directories. Here we setup kerberos using OpenLDAP as the backend to store the principals. This allows one to easily replicate the data to slave servers.</p>
<p>The following documents were used to get the configuration working:</p>
<ul>
<li><a href="https://help.ubuntu.com/community/SingleSignOn">Ubuntu SingleSignOn manual page</a></li>
</ul>
<p>This example uses kerberos realm EDU.EXAMPLE.ORG and the kdc uses fqdn kerberos.edu.example.org. The ldap database used is the same as configured in the earlier postings in this blog.</p>
<p>The following packages are needed to get kerberos working with ldap backend:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo apt-get install krb5-kdc-ldap krb5-kdc krb5-admin-server krb5-config krb5-user</pre>
</div>
<p>/etc/krb5.conf configures the database location that is needed before initializing the ldap database. In this example the ldap connection does not use TLS as both are running on the same server.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[libdefaults]
        default_realm = EDU.EXAMPLE.ORG

[realms]
         EDU.EXAMPLE.ORG = {
             kdc = kerberos.edu.example.org
             admin_server = kerberos.edu.example.org
             master_kdc = kerberos.edu.example.org
             default_domain = edu.example.org
             database_module = ldap_edu.example.org
         }

[domain_realm]
         .edu.example.org = EDU.EXAMPLE.ORG
         edu.example.org = EDU.EXAMPLE.ORG

[dbmodules]
        ldap_edu.example.org = {
               db_library = kldap
               ldap_kerberos_container_dn = cn=krbcontainer,dc=edu,dc=example,dc=org
               ldap_kdc_dn = uid=admin,ou=People,dc=edu,dc=example,dc=org
               ldap_kadmind_dn = uid=admin,ou=People,dc=edu,dc=example,dc=org
               ldap_service_password_file = /etc/krb5.secrets
               ldap_servers = ldap://127.0.0.1
               ldap_conns_per_server = 5
        }</pre>
</div>
<p>To get the kerberos database initialized in the ldap directory, kdb5_ldap_util is used with valid ldap credentials. Kerberos will use these credentials to create the initial entries. Also KDC database master key is set at this point. Make it difficult and write it down somewhere.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo kdb5_ldap_util -D uid=admin,ou=People,dc=edu,dc=example,dc=org \
create -subtrees dc=edu,dc=example,dc=org -s -H ldap://localhost -r EDU.EXAMPLE.ORG

Password for "uid=admin,ou=People,dc=edu,dc=example,dc=org":
Initializing database for realm 'EDU.EXAMPLE.ORG'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key:
Re-enter KDC database master key to verify:

Kerberos container is missing. Creating now...</pre>
</div>
<p>Some hints for potential errors:</p>
<ul>
<li>
<i>&#8220;kdb5_ldap_util: Kerberos container location not specified while reading kerberos container information&#8221;</i> &#8211; /etc/krb5.conf has<br />
something wrong so that the realm doesn&#8217;t map to any databases</li>
<li>
<i>Server is unwilling to perform</i> &#8211; the ldap suffix configured for the realm is probably not valid</li>
</ul>
<p>Next the ldap user and password are stored for KDC to access and create principals:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo kdb5_ldap_util -D uid=admin,ou=People,dc=edu,dc=example,dc=org \
  stashsrvpw -f /etc/krb5.secrets uid=admin,ou=People,dc=edu,dc=example,dc=org</pre>
</div>
<p>Create an admin user named john who can modify the database:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo kadmin.local -q "addprinc john/admin@EDU.EXAMPLE.ORG</pre>
</div>
<p>Finally give the user access rights in /etc/krb5kdc/kadm5.acl:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
*/admin *</pre>
</div>
<p>KDC is configured in /etc/krb5kdc/kdc.conf with fairly basic configuration:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[kdcdefaults]
    kdc_ports = 750,88

[realms]
    EDU.EXAMPLE.ORG = {
        database_name = /var/lib/krb5kdc/principal
        admin_keytab = FILE:/etc/krb5kdc/kadm5.keytab
        acl_file = /etc/krb5kdc/kadm5.acl
        key_stash_file = /etc/krb5kdc/stash
        kdc_ports = 750,88
        max_life = 10h 0m 0s
        max_renewable_life = 7d 0h 0m 0s
        master_key_type = des3-hmac-sha1
        supported_enctypes = aes256-cts:normal arcfour-hmac:normal des3-hmac-sha1:normal des-cbc-crc:normal des:normal des:v4 des:norealm des:onlyrealm des:afs3
        default_principal_flags = +preauth
    }</pre>
</div>
<p>After restarting krb5-kdc and krb5-admin-server one should be able to run kinit and get a kerberos ticket:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
$ kinit john/admin
Password for john/admin@EDU.EXAMPLE.ORG:
$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: john/admin@EDU.EXAMPLE.ORG

Valid starting     Expires            Service principal
01/28/10 03:10:20  01/29/10 03:10:20  krbtgt/EDU.EXAMPLE.ORG@EDU.EXAMPLE.ORG</pre>
</div>
<p>If you now dump the ldap database, the principal for john/admin is stored in dn: krbPrincipalName=john/admin@EDU.EXAMPLE.ORG,cn=EDU.EXAMPLE.ORG, cn=krbcontainer,dc=edu,dc=example,dc=org</p>
<p>More user principals can be added with kadmin and kadmin.local using the addprinc command. The <a href="https://help.ubuntu.com/community/SingleSignOn">Ubuntu SingleSignOn manual page</a> has more information about that.</p>
<h2>Desktop logins using kerberos</h2>
<p>Getting client machines to do PAM authentication using kerberos is easy. The libpam-krb5 package is needed for this:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo apt-get install libpam-krb5</pre>
</div>
<p>/etc/krb5.conf needs to be configured on the clients to point to the right server. This can be done also using proper name server settings to instruct the kerberos clients to contact the right server based on dns names.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
[libdefaults]
        default_realm = EDU.EXAMPLE.ORG

[realms]
         EDU.EXAMPLE.ORG = {
             kdc = kerberos.edu.example.org
             admin_server = kerberos.edu.example.org
             master_kdc = kerberos.edu.example.org
             default_domain = edu.example.org
         }</pre>
</div>
<p>On Lucid the PAM settings are added automagically and you should be ready to rock. Just make sure that the user you are authenticating as actually exists in /etc/passwd or ldap as kerberos does not provide nss services.</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Setting up OpenLDAP on Ubuntu 10.04 Alpha 2 (Lucid), part 3</title>
		<link>http://www.opinsys.fi/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3</link>
		<comments>http://www.opinsys.fi/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3#comments</comments>
		<pubDate>Mon, 01 Feb 2010 05:30:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer's blog]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[OpenLDAP]]></category>
		<category><![CDATA[schema]]></category>

		<guid isPermaLink="false">http://www.opinsys.fi/?p=936</guid>
		<description><![CDATA[<!--:fi-->In this part I'm setting up ldap schemas for samba, autofs and kerberos. This is needed before the actual configuration for these can be done. Unfortunately I could not find ldif files for OpenLDAP for these, so the schema files need to be converted to ldif files. The tutorial at help.ubuntu.com instructs to use the slaptest tool for this.<!--:--><!--:se-->In this part I'm setting up ldap schemas for samba, autofs and kerberos. This is needed before the actual configuration for these can be done. Unfortunately I could not find ldif files for OpenLDAP for these, so the schema files need to be converted to ldif files. The tutorial at help.ubuntu.com instructs to use the slaptest tool for this.<!--:--><!--:en-->In this part I'm setting up ldap schemas for samba, autofs and kerberos. This is needed before the actual configuration for these can be done. Unfortunately I could not find ldif files for OpenLDAP for these, so the schema files need to be converted to ldif files. The tutorial at help.ubuntu.com instructs to use the slaptest tool for this.<!--:-->]]></description>
			<content:encoded><![CDATA[<p>This blog posting is a part of a series of blog postings:</p>
<ul>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha2">Part 1 &#8211; OpenLDAP setup</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-lucid-part2">Part 2 &#8211; SSL/TLS</a></li>
<li><a href="/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3">Part 3 &#8211; Schemas for samba, autofs and kerberos</a></li>
<li><a href="/en/setting-up-openldap-kerberos-on-ubuntu-10-04-lucid">Part 4 &#8211; Kerberos setup</a></li>
<li><a href="/en/setting-up-openldapkerberos-on-ubuntu-10-04-alpha-2-lucid-part-5-dns-settings">Part 5 &#8211; DNS settings for kerberos using dnsmasq</a></li>
<li><a href="/en/setting-up-nfsv4kerberos-on-ubuntu-10-04-alpha-2-lucid-part-6">Part 6 &#8211; NFSv4 with kerberos</a></li>
<li><a hreF="/en/setting-up-nfsv4kerberosautofs5-ldap-on-ubuntu-10-04-alpha-2-lucid-part-7">Part 7 &#8211; Autofs</a></li>
</ul>
<p>In this part I&#8217;m setting up ldap schemas for samba, autofs and kerberos. This is needed before the actual configuration for these can be done. Unfortunately I could not find ldif files for OpenLDAP for these, so the schema files need to be converted to ldif files. The tutorial at <a href="https://help.ubuntu.com/9.10/serverguide/C/openldap-server.html">help.ubuntu.com</a> instructs to use the slaptest tool for this.</p>
<p>First get the tools and packages that contain the schemas that need to be converted. autofs.schema is in the autofs-ldap package, samba.schema is in the samba sources and kerberos.schema come with the krb5-kdc-ldap package.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo apt-get install dpkg-dev autofs-ldap krb5-kdc-ldap

apt-get source samba

cp ./samba-3.4.3/examples/LDAP/samba.schema .
cp /etc/ldap/schema/autofs.schema .
cp /usr/share/doc/krb5-kdc-ldap/kerberos.schema.gz .
gunzip kerberos.schema.gz</pre>
</div>
<p>schema_convert.conf is a temporary file used to convert the schemas to ldif format:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/inetorgperson.schema
include samba.schema
include autofs.schema
include kerberos.schema</pre>
</div>
<p>The actual conversion is done by running slaptest. It places the the resulting files under ldif_result directory. The files need to be cleaned a bit so that they are be imported. This is not exactly the nicest looking piece I&#8217;ve written, but it seems to do the trick.</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
mkdir ldif_result
slaptest -f schema_convert.conf -F ldif_result

cat ldif_result/cn=config/cn=schema/cn=*samba.ldif | \
egrep -v structuralObjectClass\|entryUUID\|creatorsName  | \
egrep -v createTimestamp\|entryCSN\|modifiersName\|modifyTimestamp | \
sed 's/dn: cn={.}samba/dn: cn=samba,cn=schema,cn=config/g' | \
sed 's/{.}samba/samba/' &gt; samba.ldif

cat ldif_result/cn=config/cn=schema/cn=*autofs.ldif | \
egrep -v structuralObjectClass\|entryUUID\|creatorsName  | \
egrep -v createTimestamp\|entryCSN\|modifiersName\|modifyTimestamp | \
sed 's/dn: cn={.}autofs/dn: cn=autofs,cn=schema,cn=config/g' | \
sed 's/{.}autofs/autofs/' &gt; autofs.ldif

cat ldif_result/cn=config/cn=schema/cn=*kerberos.ldif | \
egrep -v structuralObjectClass\|entryUUID\|creatorsName  | \
egrep -v createTimestamp\|entryCSN\|modifiersName\|modifyTimestamp | \
sed 's/dn: cn={.}kerberos/dn: cn=kerberos,cn=schema,cn=config/g' | \
sed 's/{.}kerberos/kerberos/' &gt; kerberos.ldif

sudo cp samba.ldif autofs.ldif kerberos.ldif /etc/ldap/schema/</pre>
</div>
<p>The ldif files are now placed under /etc/ldap/schema/ and can be added using ldapadd:</p>
<div style="border-width: 1px;background:#ddffaa;margin-bottom:10pt">
<pre>
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/samba.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/autofs.ldif
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/kerberos.ldif</pre>
</div>
<p>Next it&#8217;s time to finally get to kerberos, I hope..</p>
<p>Veli-Matti Lintu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opinsys.fi/en/setting-up-openldap-on-ubuntu-10-04-alpha-2-lucid-part-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
