<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ryan Lane's Blog » pki</title>
	
	<link>http://ryandlane.com/blog</link>
	<description />
	<lastBuildDate>Thu, 29 Jul 2010 13:56:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RyanLanesBlog_pki" /><feedburner:info uri="ryanlanesblog_pki" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://superfeedr.com/hubbub" /><item>
		<title>Requiring SSL client authentication in a user friendly way in Apache</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/Ho5ZUGyDRTM/</link>
		<comments>http://ryandlane.com/blog/2010/07/29/requiring-ssl-client-authentication-in-a-user-friendly-way-in-apache/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 13:56:34 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/blog/?p=316</guid>
		<description><![CDATA[Web browsers don&#8217;t display very friendly error messages to users when SSL client authentication fails. What most people understand from the error message displayed is &#8220;This site doesn&#8217;t work for me&#8221;. This is a usability failure. Your site should always display useful error messages to your users. Another common usability failure is to allow users [...]]]></description>
			<content:encoded><![CDATA[<p>Web browsers don&#8217;t display very friendly error messages to users when SSL client authentication fails. What most people understand from the error message displayed is &#8220;This site doesn&#8217;t work for me&#8221;. This is a usability failure. Your site should always display useful error messages to your users.</p>
<p>Another common usability failure is to allow users to present multiple client certificates when your site only trusts a certain type of certificate. The user has no idea which certificate they need to present, and they shouldn&#8217;t need to. The common solution to this problem is to provide documentation as to which certificate should be used. This is a poor solution.</p>
<p>In this article, I&#8217;ll describe how to configure Apache to require SSL client authentication in a polite, usable way.</p>

<h2>Politely requiring SSL client authentication</h2>
<p>I&#8217;m using &#8220;require&#8221; somewhat loosely here, as that&#8217;s the first thing we are going to change in our configuration. When you use the <strong>SSLVerifyClient</strong> directive with the <strong>require</strong> value, it <em>really</em> means require. So, how do we get around this?</p>
<p>We change the <strong>SSLVerifyClient</strong> directive to the <strong>optional</strong> value. The key is making <strong>optional</strong> still mean <strong>require</strong>. Our goal is to redirect users to help documentation when SSL client authentication fails. We can do this by using mod_rewrite and environment variables from mod_ssl. Here&#8217;s how to configure this in Apache:</p>
<pre style="padding-left: 30px;">SSLOptions +StdEnvVars
SSLVerifyClient optional
SSLVerifyDepth 3
RewriteEngine On
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
RewriteRule .* /help/ssl-client-auth-required.html [L]</pre>
<p>In this configuration, any request that doesn&#8217;t have a valid client certificate will be redirected to a help file. Optional, yet required <em>politely</em>. Don&#8217;t forget to be polite internationally, if that is a requirement! You should configure Apache to serve the help document based on the user&#8217;s language. I&#8217;m going to avoid this portion of the topic for now. I&#8217;ll go into this in a future article.</p>
<h2>Selectively accepting client certificates</h2>
<p>If your users have multiple types of client certificates; for email, client authentication, and encryption from different intermediate CAs; for instance; and your application needs a specific type of certificate; then you shouldn&#8217;t force your users to guess which certificate is required. There are a few options here:</p>
<ol>
<li>Provide documentation to educate users on which certificate to choose prior to them accessing the site</li>
<li>Use the above method to educate users when they fail to choose the correct certificate</li>
<li>Use both options 1 and 2</li>
<li>Only allow users to choose the correct certificate by limiting which certificates your site will accept</li>
</ol>
<p>The obvious choice from a usability perspective is option 4. It is less confusing, requires less documentation to be written and read, and is fairly easy to configure.</p>
<p>The first step is to identify which certificate authorities (CA)s you wish to trust. The next step is to append all of the public CA certificates into a single file. The final step is to configure Apache to use this file to restrict certificates. To configure this in Apache, use the following directive:</p>
<pre style="padding-left: 30px;">SSLCADNRequestFile /etc/pki/tls/certs/client-trust-bundle.cer</pre>
<p>Unfortunately, option 4 will only be a viable option if the different certificate types were created by different CAs (which, hopefully, you are doing for security reasons). If you are unable to use option 4, you should use option 3.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;submitHeadline=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F&amp;title=Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Requiring+SSL+client+authentication+in+a+user+friendly+way+in+Apache+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F07%2F29%2Frequiring-ssl-client-authentication-in-a-user-friendly-way-in-apache%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
<img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/Ho5ZUGyDRTM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2010/07/29/requiring-ssl-client-authentication-in-a-user-friendly-way-in-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2010/07/29/requiring-ssl-client-authentication-in-a-user-friendly-way-in-apache/</feedburner:origLink></item>
		<item>
		<title>Graphical login into Unix/Linux systems from Cygwin using SSH</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/Svxx6TyU1fA/</link>
		<comments>http://ryandlane.com/blog/2010/06/07/graphical-login-to-unix-and-linux-system-from-cygwin-using-ssh/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 22:57:29 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Red Hat]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/blog/?p=276</guid>
		<description><![CDATA[XDMCP is insecure when used directly, as it is unencrypted, and will send your credentials and all keystrokes and mouse actions  over the network in clear text. By default XDMCP is disabled on most recent distros. Thankfully there isn&#8217;t any reason to use it! Instead of using XDMCP, you can use X11 forwarding to run [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin'>Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>XDMCP is insecure when used directly, as it is unencrypted, and will send your credentials and <em>all</em> keystrokes and mouse actions  over the network in clear text. By default XDMCP is disabled on most recent distros. Thankfully there isn&#8217;t any reason to use it!</p>
<p>Instead of using XDMCP, you can use X11 forwarding to run your graphical environments across SSH. Doing so also allows you to <a href="http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/">log in via smart cards</a>, if your version of SSH has PKCS11 support.</p>
<p>I&#8217;ve written a script called <a href="http://ryandlane.com/blog/wp-content/uploads/2010/06/remote-graphical-login.zip">remote-graphical-login</a> to make this much easier. Note that this script has smartcard support built in, and may not work properly if the libraries do not exist on your system. In a future version I&#8217;ll make this configurable so that it can be used with identity files, or without an agent. Here&#8217;s the usage:</p>
<pre>Usage: remote-graphical-login.sh [-s session] [-I cardlib] [-l username] [username@][hostname]
        -s      kde or gnome (default)
        -I      coolkey or activclient (default)
        -l      Username to login with
Example: remote-graphical-login.sh -s kde testuser@testhost</pre>
<p>There may be a few bugs in the script. Let me know if you run into any.</p>
<p><strong>Update (06/14/10):</strong> Fixed some issues in the script. Notably, the X launcher did exactly the opposite of what it was intended to do. If an X server was already running, it would re-use that server. The intended action was for the script to start a new X server on another display number. This is now fixed. Also, an informational message will now be shown to users when they do not specify a username or hostname, mentioning the ability to do so.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;submitHeadline=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F&amp;title=Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Graphical+login+into+Unix%2FLinux+systems+from+Cygwin+using+SSH+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F07%2Fgraphical-login-to-unix-and-linux-system-from-cygwin-using-ssh%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin'>Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/Svxx6TyU1fA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2010/06/07/graphical-login-to-unix-and-linux-system-from-cygwin-using-ssh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2010/06/07/graphical-login-to-unix-and-linux-system-from-cygwin-using-ssh/</feedburner:origLink></item>
		<item>
		<title>Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/8xstxPmvT9g/</link>
		<comments>http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 20:55:30 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/blog/?p=262</guid>
		<description><![CDATA[At some point recently the SSH shipped with Cygwin added PKCS11 support. This support allows you to add a smart card library to use your smart card&#8217;s certificates as ssh keys. This article will describe how to use ActivClient or Coolkey to access your card, how to export the card&#8217;s public certificates (as rsa public [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
<li><a href='http://ryandlane.com/blog/2010/06/07/graphical-login-to-unix-and-linux-system-from-cygwin-using-ssh/' rel='bookmark' title='Permanent Link: Graphical login into Unix/Linux systems from Cygwin using SSH'>Graphical login into Unix/Linux systems from Cygwin using SSH</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>At some point recently the SSH shipped with Cygwin added PKCS11 support. This support allows you to add a smart card library to use your smart card&#8217;s certificates as ssh keys. This article will describe how to use ActivClient or Coolkey to access your card, how to export the card&#8217;s public certificates (as rsa public keys), and how to use ssh/ssh-agent options to properly use the smart card.</p>

<h2>Prerequisites</h2>
<p>I&#8217;ve tested with the below software and versions. Other versions may work, but haven&#8217;t been tested.</p>
<ul>
<li>ActivClient 6.2+ or <a href="http://directory.fedoraproject.org/wiki/CoolKey">Coolkey</a></li>
<li>Cygwin 1.7+
<ul>
<li>OpenSSH_5.5p1+</li>
<li>OpenSSL 0.9.8n+</li>
</ul>
</li>
</ul>
<p>Obviously you&#8217;ll also need a smart card, and a supported smart card reader.</p>
<p>All the instructions below pertain to either ActivClient, or Coolkey. You need one or the other, not both. Coolkey is FOSS, and works, if you do not wish to buy ActivClient; for the full FOSS smart card suite, see the <a href="http://directory.fedoraproject.org/wiki/ESC_Guide">ESC guide</a>.</p>
<p>Some of the following instructions assume you are typing commands into a Cygwin window that has an SSH agent started the following way:</p>
<pre style="padding-left: 30px;">ssh-agent /bin/bash
</pre>
<h2>Add the reader library</h2>
<h3>ActivClient</h3>
<p>Add the <em>acpkcs211.dll</em> to your agent:</p>
<pre style="padding-left: 30px;">ssh-agent -s acpkcs211.dll
</pre>
<h3>Coolkey</h3>
<p>Add the <em>libcoolkeypk11.dll</em> to your agent:</p>
<pre style="padding-left: 30px;">ssh-agent -s libcoolkeypk11.dll</pre>
<h2>Export the card&#8217;s public certificates</h2>
<p>You can export the public certificates with an agent running with the following command:</p>
<pre style="padding-left: 30px;">ssh-add -L</pre>
<p>You can export the public certificates without an agent with the following command for ActivClient:</p>
<pre style="padding-left: 30px;">ssh-keygen -D acpkcs211.dll
</pre>
<p>You can export the public certificates without an agent with the following command for Coolkey:</p>
<pre style="padding-left: 30px;">ssh-keygen -D libcoolkeypk11.dll</pre>
<h2>Add the public certificates to your authorized_keys file</h2>
<p>If you have an agent running, you can have the keys automatically added to your authorized_keys file by running the following command:</p>
<pre style="padding-left: 30px;">ssh-copy-id [user@]&lt;hostname&gt;
</pre>
<p>If you do not have an agent running, copy the output from the section above, and manually append it to the end of your authorized_keys file.</p>
<h2>Signing into a system using the card&#8217;s certificates</h2>
<p>If you are using an agent, you simply need to ssh as you normally would. If you are not using an agent, there are two different ways to use the card:</p>
<h3>Using ActivClient</h3>
<pre style="padding-left: 30px;">ssh -I acpkcs211.dll [user@]&lt;hostname&gt;
</pre>
<p>or:</p>
<pre style="padding-left: 30px;">ssh -o PKCS11Provider=acpkcs211.dll [user@]&lt;hostname&gt;
</pre>
<h3>Using Coolkey</h3>
<pre style="padding-left: 30px;">ssh -I libcoolkeypk11.dll [user@]&lt;hostname&gt;</pre>
<p>or:</p>
<pre style="padding-left: 30px;">ssh -o PKCS11Provider=libcoolkeypk11.dll [user@]&lt;hostname&gt;</pre>
<p>If you notice, the second method is using an SSH configuration option, which means you can add this to your user or system configuration file so that the card&#8217;s library will be used by default.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;submitHeadline=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F&amp;title=Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Using+ActivClient+or+Coolkey+with+SSH+for+Smart+Card+Login+using+Cygwin+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2010%2F06%2F03%2Fusing-activclient-or-coolkey-with-openssh-for-smart-card-login%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
<li><a href='http://ryandlane.com/blog/2010/06/07/graphical-login-to-unix-and-linux-system-from-cygwin-using-ssh/' rel='bookmark' title='Permanent Link: Graphical login into Unix/Linux systems from Cygwin using SSH'>Graphical login into Unix/Linux systems from Cygwin using SSH</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/8xstxPmvT9g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/</feedburner:origLink></item>
		<item>
		<title>Documentation sorely missing from NSS</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/gErtVCW09Vk/</link>
		<comments>http://ryandlane.com/blog/2009/07/24/documentation-sorely-missing-from-nss/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 02:52:46 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=177</guid>
		<description><![CDATA[I&#8217;m a masochist, and subscribe to the entirety of Sun Microsystem&#8217;s blog feed. At least 90% of that content is completely worthless to me; however, the 10% that is worthwhile is usually really worthwhile. This post about managing certificate trust flags in Network Security Services (NSS) databases is part of that 10%, and is the [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/' rel='bookmark' title='Permanent Link: SSL replication and CA trusts in Sun Directory Server 6.x'>SSL replication and CA trusts in Sun Directory Server 6.x</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a masochist, and subscribe to the entirety of <a href="http://blogs.sun.com/main/feed/entries/atom">Sun Microsystem&#8217;s blog feed</a>. At least 90% of that content is completely worthless to me; however, the 10% that is worthwhile is usually <em>really</em> worthwhile.</p>
<p><a href="http://blogs.sun.com/meena/entry/notes_about_trust_flags">This post</a> about managing certificate trust flags in Network Security Services (NSS) databases is part of that 10%, and is the kind of thing everyone dealing with NSS should read. It is crazy that this information is missing from <a href="http://www.mozilla.org/projects/security/pki/nss/tools/certutil.html">Mozilla&#8217;s documentation on certutil</a>; this really makes the trust flags clear!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;submitHeadline=Documentation+sorely+missing+from+NSS&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F&amp;title=Documentation+sorely+missing+from+NSS" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Documentation+sorely+missing+from+NSS+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F07%2F24%2Fdocumentation-sorely-missing-from-nss%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/' rel='bookmark' title='Permanent Link: SSL replication and CA trusts in Sun Directory Server 6.x'>SSL replication and CA trusts in Sun Directory Server 6.x</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/gErtVCW09Vk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2009/07/24/documentation-sorely-missing-from-nss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2009/07/24/documentation-sorely-missing-from-nss/</feedburner:origLink></item>
		<item>
		<title>SSL replication and CA trusts in Sun Directory Server 6.x</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/_acvl6xX91Y/</link>
		<comments>http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 18:26:18 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[LDAP]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=146</guid>
		<description><![CDATA[If, like me, you have had issues with replication in Sun Directory Server, maybe this post will help. The dsadm list-certs -C command will show you what CA certificates you are trusting, but it won&#8217;t show you how it is trusting a certificate. If you are getting an error like &#8220;Bind failed with response: Failed [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If, like me, you have had issues with replication in Sun Directory Server, maybe this post will help.</p>
<p>The <strong>dsadm list-certs -C</strong> command will show you <em>what</em> CA certificates you are trusting, but it won&#8217;t show you <em>how</em> it is trusting a certificate. If you are getting an error like &#8220;Bind failed with response: Failed to bind to remote (900).&#8221;, and you <em>know</em> SSL should be working properly, you probably want to check to see exactly how your CA certificates are being trusted.</p>
<p>To do this, use the <strong>certutil</strong> command:</p>
<pre style="padding-left: 30px;">certutil -L -d /var/opt/SUNWdsee/dsins1/alias -P slapd-</pre>
<p>The trust <em>should</em> show as &#8220;CT,,&#8221;. If it is showing as &#8220;c,c,c&#8221; or pretty much anything else, your CA certificate isn&#8217;t trusted properly. You can remove the  certificate and re-add it using certutil in the following ways:</p>
<pre style="padding-left: 30px;">certutil  -D -n "&lt;your CA cert's alias&gt;" -P slapd- -d /var/opt/SUNWdsee/dsins1/alias
certutil  -A -n "&lt;your CA cert's alias&gt;" -P slapd- -d /var/opt/SUNWdsee/dsins1/alias -i &lt;location of your CA cert&gt; -a</pre>
<p>Now restart your directory server, and test replication. If you are lucky, this is your problem.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;submitHeadline=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F&amp;title=SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+SSL+replication+and+CA+trusts+in+Sun+Directory+Server+6.x+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2009%2F06%2F19%2Fssl-replication-and-ca-trusts-in-sun-directory-server-6-x%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/_acvl6xX91Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/</feedburner:origLink></item>
		<item>
		<title>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/ncL-uYmAwt0/</link>
		<comments>http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 23:28:24 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[LDAP]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=34</guid>
		<description><![CDATA[In part 1 I discussed how to configure NSS and OpenSSL. In part 2, I discussed how to configure pam_pkcs11 and how to test a smartcard against the NSS database we set up. In this part, I&#8217;ll discuss how to add pam_krb5 into the mix to automatically get a Kerberos ticket from an Active Directory [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In <a href="../2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/">part 1</a> I discussed how to configure NSS and OpenSSL. In <a href="http://ryandlane.com/wprdl/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/">part 2</a>, I discussed how to configure pam_pkcs11 and how to test a smartcard against the NSS database we set up. In this part, I&#8217;ll discuss how to add pam_krb5 into the mix to automatically get a Kerberos ticket from an Active Directory domain using PKINIT.</p>
<p>Notice that this post will discuss a package that is yet to be officially released by Red Hat. Whenever this is officially released, it may have different configuration options, or different functionality. I&#8217;ll update this post at that time.<br />
</p>
<h2>Configure the krb5.conf</h2>
<p>Add the following information into the <tt>[libdefaults]</tt> section:</p>
<pre>        default_realm = EXAMPLE.COM</pre>
<p>This tells the Kerberos client that by default, it will use the EXAMPLE.COM realm unless otherwise specified. If you are in an environment where another Kerberos realm is supposed to be your default, you can skip the <tt>[libdefaults]</tt> section. Later, I&#8217;ll show you how pam_krb5 can work without this configuration setting.</p>
<p>Add the following information into the <tt>[realms]</tt> section:</p>
<pre>        EXAMPLE.COM = {
                kdc = kdc1.example.com
                kdc = kdc2.example.com
                admin_server = kdc1.example.com
                default_domain = example.com
        }</pre>
<p>This tells the Kerberos client about the EXAMPLE.COM domain; specifically: what the servers are, and the default domain.</p>
<p>Add the following into the <tt>[domain_realm]</tt> section:</p>
<pre>        .example.com = EXAMPLE.COM</pre>
<p>This maps the DNS domain name to the Kerberos domain name; if you have service records for your Active Directory domain, this may not be necessary.</p>
<p>Add the following into the <tt>[appdefaults]</tt> section:</p>
<pre>        allow_pkinit = yes
        pkinit = {
                client_ca_certificate_pool = /etc/pki/tls/certs
                EXAMPLE.COM = {
                        trusted_guid = f7:11:44:70:97:a8:40:d8:bb:a1:b8:7f:4e:a2:ed:fe 51:6d:28:dd:57:af:4d:b5:90:09:00:a1:c0:39:48:a2
                        is_hw = yes
                        pkinit_cert_match = &amp;&amp;&lt;EKU&gt;msScLogin,&lt;KU&gt;digitalSignature
                }
        }</pre>
<p>This is where the magic happens. First we tell the Kerberos client to allow pkinit (which is for pre-authentication, aka token login). Next we make a section for pkinit, tell it where the PEM (ascii) encoded CA certs are, and make a section for our domain. In the domain section, we tell the Kerberos client which servers to trust, that the token is a hardware token, and the criteria needed for a valid login certificate from the smartcard.</p>
<p>The <tt>pkinit_cert_match</tt> field has the following documentation in the version of pkinit-nss that I am discussing:</p>
<blockquote><p>pkinit_cert_match   &#8211; Alternate combinations of client certificate<br />
characteristics which would cause it to be deemed<br />
sufficient for use.  Rules are specified as combinations<br />
of fields and specifications in the form<br />
[&amp;&amp;]&lt;FIELD1&gt;spec1[,&lt;FIELD2&gt;spec2[,...]] [...]<br />
&lt;FIELD1&gt;spec1[,&lt;FIELD2&gt;spec2[,...]] [...]<br />
[||]&lt;FIELD1&gt;spec1[,&lt;FIELD2&gt;spec2[,...]] [...]<br />
Recognized fields and the types of specifications to be<br />
used include<br />
&lt;SUBJECT&gt;     Regular expression.<br />
&lt;ISSUER&gt;      Regular expression.<br />
&lt;SAN&gt;         Regular expression.<br />
&lt;EKU&gt;         List of zero or more values, possibly<br />
including &#8220;pkinit&#8221;, &#8220;msScLogin&#8221;,<br />
&#8220;clientAuth&#8221;, and &#8220;emailProtection&#8221;.<br />
&lt;KU&gt;          List of zero or more values, possibly<br />
including &#8220;digitalSignature&#8221; and<br />
&#8220;keyEncipherment&#8221;.<br />
There is no default.</p></blockquote>
<p>pkinit-nss needs to match exactly one certificate off of your smartcard; you can use these criteria to specify which certificate will be used. Notice that in the above configuration I chose a certificate that was allowed for Microsoft Smart Card Login, and was a digital signature type of certificate.</p>
<p>Notice that the guids are collected via the <tt>pkinit-show-cert-guid</tt> command, and that they are space delimited.</p>
<h3>Collecting server guids</h3>
<ol>
<li>Get the server&#8217;s public certificate
<ol>
<li><tt>openssl s_client -connect kdc1.example.com:636</tt></li>
<li>Find the section that starts with &#8220;BEGIN CERTIFICATE&#8221; and ends with &#8220;END CERTIFICATE&#8221;; copy everything including the begin and end sections, and paste it into a file</li>
</ol>
</li>
<li>Use <tt>pkinit-show-cert-guid</tt> on the file to get the guid
<ul>
<li><tt>pkinit-show-cert-guid &lt;file&gt;</tt></li>
</ul>
</li>
<li>Repeat for every Active Directory server</li>
</ol>
<h2>Configure PAM</h2>
<p>The following is an example <tt>/etc/pam.d/system-auth</tt> file:</p>
<pre>auth        required      pam_env.so
auth        [success=2 default=ignore] pam_succeed_if.so service notin login:gdm:xdm:kdm:xscreensaver:gnome-screensaver:kscreensaver quiet use_uid
auth        [success=ok authinfo_unavail=2 ignore=2 default=die] pam_pkcs11.so
auth        [default=ignore] pam_krb5.so no_subsequent_prompt no_initial_prompt
auth        sufficient    pam_permit.so
auth        sufficient    pam_unix.so likeauth
auth        required      pam_deny.so

account     required      pam_unix.so broken_shadow
account     sufficient    pam_localuser.so
account     sufficient    pam_krb5.so
account     required      pam_permit.so

password    optional      pam_pkcs11.so
password    requisite     pam_cracklib.so retry=3 dcredit=-1 ucredit=-1 ocredit=-1 lcredit=-1 minlen=10
password    sufficient    pam_unix.so md5 shadow try_first_pass use_authtok remember=5
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     optional      pam_krb5.so
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so</pre>
<p>It is important to understand what is happening in the auth stack here. Read the following three lines carefully:</p>
<pre>auth        [success=ok authinfo_unavail=2 ignore=2 default=die] pam_pkcs11.so
auth        [default=ignore] pam_krb5.so no_subsequent_prompt no_initial_prompt
auth        sufficient    pam_permit.so</pre>
<p>The first line says if pam_pkcs11 succeeds, continue on; if a card isn&#8217;t available, or we can&#8217;t map the card identity to a user, skip the next two lines; if the user puts his pin in incorrectly, exit with a failure. The second line says don&#8217;t prompt for a pin, don&#8217;t prompt for a password if the pin fails, and ignore the return value of pam_krb5. The third line says no matter what, return success.</p>
<p>This configuration ensures a few things:</p>
<ol>
<li>Ensures if the user types her pin in incorrectly, it won&#8217;t cause two incorrect pins against the card</li>
<li>Ensures that the system will only try to get a Kerberos ticket if the user is using a card</li>
<li>Ensures that the user can log into the system with a card even if they can&#8217;t get a Kerberos ticket
<ul>
<li>If you wish to require valid Kerberos authentication, pam_krb5 should be marked as &#8220;required&#8221;, the pam_success line should be removed, and the pam_pkcs11 module line&#8217;s arguments should be changed to &#8220;authinfo_unavail=1 ignore=1&#8243;</li>
</ul>
</li>
</ol>
<p>Notice that if you are trying to completely eliminate passwords, that this PAM configuration won&#8217;t fully do it. This configuration still allows password authentication to the local system. You should tweak this configuration as necessary. Remember, however, that you likely don&#8217;t wish to lock root out of the system &#8211; so be careful!</p>
<p>As I mentioned earlier, if your default Kerberos domain cannot be your Active Directory domain, you can specify it explicitly in the PAM configuration; to do this, your auth line for pam_krb5 would change to the following:</p>
<pre>auth        [default=done] pam_krb5.so realm=EXAMPLE.COM no_subsequent_prompt no_initial_prompt</pre>
<h2>Conclusion</h2>
<p>This series should be a good starting ground for getting your PKI environment set up on your RHEL systems. In the future I will discuss more ways to eliminate passwords by using Smart Card authentication.</p>
<p>If you have any questions, please be sure to leave a comment!</p>
<p><strong>Update (04/24/2009):</strong> I updated the krb5.conf configuration.</p>
<p><code>pkinit_cert_match = &amp;&amp;msScLogin,digitalSignature</code></p>
<p>should have read as:</p>
<p><code>pkinit_cert_match = &amp;&amp;&lt;EKU&gt;msScLogin,&lt;KU&gt;digitalSignature</code></p>
<p><strong>Update (05/12/2009):</strong> The PAM configuration was slightly incorrect. The way it was previously written would deny users access if pam_krb failed.<br />
<strong>Update (05/26/2009):</strong> The openssl s_client command was slightly incorrect; I changed &#8220;connect&#8221; to &#8220;-connect&#8221;.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;submitHeadline=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+3%29+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/ncL-uYmAwt0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/</feedburner:origLink></item>
		<item>
		<title>Using NSS with OpenSSH for Smart Card Login</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/ulqSnEt0Qk4/</link>
		<comments>http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:14:58 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[pki]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=29</guid>
		<description><![CDATA[At some point in time, Red Hat snuck in experimental support for NSS in OpenSSH. What does that give us? Smart Card support! This article will describe how to use it. In another blog post, I mentioned how to configure NSS and OpenSSL; you should take a look at that if you are unfamiliar with [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin'>Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>At some point in time, Red Hat snuck in experimental support for NSS in OpenSSH. What does that give us? Smart Card support! This article will describe how to use it.</p>
<p>In another blog post, I mentioned how to <a title=" " href="http://ryandlane.com/wprdl/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/">configure NSS and OpenSSL</a>; you should take a look at that if you are unfamiliar with the process, because I assume that is prerequisite knowledge. I will also assume you have a basic understanding of how public key authentication in SSH works.</p>
<p>Here are the steps to the process:</p>
<ol>
<li>Copy the NSS databases to .ssh</li>
<li>Start an ssh-agent, if you don&#8217;t already have one running and connected</li>
<li>Add your Smart Card certificates to the ssh-agent</li>
<li>Extract a public key from one of your certificates, and put it into the authorized_keys of the host you wish to connect</li>
<li>SSH to the host</li>
</ol>
<h2>Copy the NSS database to your .ssh directory</h2>
<p>We&#8217;ll take the centralized database, and place it somewhere that OpenSSH has permissions to read and write to. The centralized database should have the coolkey module loaded, which gives access to your smart card.</p>
<pre style="padding-left: 30px;">cp /etc/pki/nssdb/*.db ~/.ssh</pre>
<h2>Start an ssh-agent</h2>
<p>First let&#8217;s see if you have an agent running:</p>
<pre style="padding-left: 30px;">env | grep 'SSH_AGENT'</pre>
<p>If you see &#8220;SSH_AGENT_PID&#8221; listed, you already have an agent running, and can skip this step. If you do not see this, you should start an agent:</p>
<pre style="padding-left: 30px;">eval `ssh-agent`</pre>
<h2>Add your Smart Card certificates to the ssh-agent</h2>
<p>This will add your certificates into the agent; notice that your keys never leave your card, so when you are SSHing back and forth, you&#8217;ll need to keep your card inserted.</p>
<p style="padding-left: 30px;">ssh-add -n</p>
<p>Take note of the certificates that got added to your agent, you&#8217;ll need them.</p>
<h2>Extract a public key from your Smart Card, and add it to the authorized_keys file</h2>
<p>You&#8217;ll need to be able to log in with at least one of the certificates from your Smart Card, so you&#8217;ll need to extract the certificate and place it into the authorized_keys file on the host you wish to connect to.</p>
<pre style="padding-left: 30px;">ssh-keygen -n -D 'My PKCS11 Token' -f 'My Key ID'</pre>
<p>You can get the &#8216;My PKCS11 Token&#8217; by using modutil:</p>
<pre style="padding-left: 30px;">modutil -list -dbdir .ssh</pre>
<p>Look for the &#8220;token:&#8221; line under the Coolkey module.</p>
<p>&#8216;My Key ID&#8217; is one of the certificates that was listed as being added to your ssh-agent.</p>
<p>The ssh-keygen command will output a public key. Take this public key, and place it into the authorized_keys file on whatever host you wish to login to with your smart card.</p>
<h2>SSH to the host</h2>
<p>Now you should be able to SSH to the host; it shouldn&#8217;t require a password, it should just log you in. You do have to use a special syntax though:</p>
<pre style="padding-left: 30px;">ssh -o 'UseNSS yes' &lt;host&gt;</pre>
<p>If ssh asks you for the password for the &#8220;NSS Certificate DB&#8221;, simply press enter. I haven&#8217;t figured out how to make it ignore that database yet (and you can&#8217;t remove the built-in NSS database).</p>
<h2>Bonus: connecting to a host without using an ssh-agent</h2>
<p>If you&#8217;d like to skip the step about using an ssh-agent, you can connect simply by using ssh:</p>
<pre style="padding-left: 30px;">ssh -o 'UseNSS yes' -o 'NSSToken &lt;My PKCS11 Token&gt;' &lt;host&gt;</pre>
<p>Like above, you can get the &lt;My PKCS11 Token&gt; by using modutil (see above section for command).</p>
<h2>See the README.nss</h2>
<p>Although the README.nss file is currently slightly incorrect on syntax, it explains the same process.</p>
<pre style="padding-left: 30px;">less /usr/share/doc/openssh-*/README.nss</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;submitHeadline=Using+NSS+with+OpenSSH+for+Smart+Card+Login&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F&amp;title=Using+NSS+with+OpenSSH+for+Smart+Card+Login" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Using+NSS+with+OpenSSH+for+Smart+Card+Login+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F12%2F08%2Fusing-nss-with-openssh-for-smart-card-login%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2010/06/03/using-activclient-or-coolkey-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin'>Using ActivClient or Coolkey with SSH for Smart Card Login using Cygwin</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/ulqSnEt0Qk4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/</feedburner:origLink></item>
		<item>
		<title>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/qBkVbyL5nZI/</link>
		<comments>http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 15:42:14 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[LDAP]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=22</guid>
		<description><![CDATA[In part 1 I discussed how to configure NSS and OpenSSL. In this part, I&#8217;ll discuss how to configure pam_pkcs11 and how to test a smartcard against the NSS database we set up. What does pam_pkcs11 do for me? The pam_pkcs11 module will do a couple things for us: Allow/Require smartcard login Map an attribute [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://ryandlane.com/wprdl/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/">part 1</a> I discussed how to configure NSS and OpenSSL. In this part, I&#8217;ll discuss how to configure pam_pkcs11 and how to test a smartcard against the NSS database we set up.<br />
</p>
<h2>What does pam_pkcs11 do for me?</h2>
<p>The pam_pkcs11 module will do a couple things for us:</p>
<ol>
<li>Allow/Require smartcard login</li>
<li>Map an attribute from the card to a login name</li>
</ol>
<p>For a basic configuration, we&#8217;ll have to edit three files; <tt>/etc/pam_pkcs11/pam_pkcs11.conf</tt>, <tt>/etc/pam_pkcs11/cn_map</tt>, and <tt>/etc/pam.d/system-auth</tt>.</p>
<h2>Configuring pam_pkcs11 and testing smart card access</h2>
<p>Edit <tt>/etc/pam_pkcs11/pam_pkcs11.conf</tt>; this file is kind of long, so I&#8217;ll just touch on specific configuration lines, and only the basic configuration lines needed to get the authentication working.</p>
<pre style="padding-left: 30px;">enable_ocsp = false;</pre>
<p>The above line tells pam_pkcs11 whether we wish to use OCSP or not. Notice that in general it is good to use OCSP if you have an OCSP available. If you do not have an OCSP server, you&#8217;ll have to manually add CRLs to your centralized NSS database. We&#8217;ll leave this set to false for testing purposes.</p>
<pre style="padding-left: 30px;">use_pkcs11_module = coolkey;</pre>
<p>The above line specifies which module the system should use to access the smart card. You should keep this configured to coolkey.</p>
<pre style="padding-left: 30px;">pkcs11_module coolkey {
  module = libcoolkeypk11.so;
  description = "Cool Key"
  # Slot-number to use. One for the first, two for the second and so
  # on. The default value is zero which means to use the first slot
  # with an available token.
  slot_num = 0;

  # Path to the directory where the CA certificates are stored. The
  # directory must contain an openssl hash-link to each certificate.
  # The default value is /etc/pam_pkcs11/cacerts.
  ca_dir = /etc/pam_pkcs11/cacerts;
  nss_dir = /etc/pki/nssdb;

  # Path to the directory where the CRLs are stored. The directory
  # must contain an openssl hash-link to each CRL. The default value
  # is /etc/pam_pkcs11/crls.
  crl_dir = /etc/pam_pkcs11/crls;

  # Sets the CRL verification policy. None performs no verification
  # at all, online downloads the CRL form the location given by the
  # CRL distribution point extension of the certificate and offline
  # uses the locally stored CRLs. Auto is a combination of online and
  # offline; it first tries to download the CRL from a possibly
  # given CRL distribution point and if this fails, uses the local
  # CRLs. The default setting is none.
  # crl_policy={none, online, offline, auto}
  crl_policy = none;

 }</pre>
<p>The above section configures the coolkey module. You should ensure &#8220;<tt>nss_dir = /etc/pki/nssdb;</tt>&#8221; and that &#8220;<tt>module = &lt;path_to_your_module&gt;;</tt>&#8220;. Notice that in the example above, I have the module line pointing explicitly to the dynamic module on the system. If you are using a 64 bit OS, this <em>may</em> not be the correct configuration. Since RHEL uses NSS and not OpenSSL for pam_pkcs11, we can ignore the <tt>ca_dir</tt>, <tt>crl_dir</tt>, and <tt>crl_policy lines</tt>.</p>
<pre style="padding-left: 30px;">use_mappers = cn, null;</pre>
<p>The above line specifies which mapping modules we wish to use, and in what order to use them. I have configured pam_pkcs11 to only use the cn module (the null module always fails by default).</p>
<pre style="padding-left: 30px;">mapper cn {
      debug = false;
      module = internal;
      # module = /usr/$LIB/pam_pkcs11/cn_mapper.so;
      ignorecase = true;
      mapfile = file:///etc/pam_pkcs11/cn_map;
}</pre>
<p>The above section configures the cn mapping module. The important line is &#8220;<tt>mapfile = file:///etc/pam_pkcs11/cn_map;</tt>&#8220;. This line tells pam_pkcs11 where to find cn to user name mappings.</p>
<p>Now we&#8217;ll need to edit the <tt>/etc/pam_pkcs11/cn_map</tt> file, and add cn to user name mappings.</p>
<pre style="padding-left: 30px;">RYAN.LANE -&gt; laner
TEST.USER -&gt; usert
external_user -&gt; usere</pre>
<p>The above lines placed in the cn_map file tell pam_pkcs11 that the CNs on the left match the user names on the right. If you don&#8217;t know what the CN of the user on the card is, you can find out using the <tt>pkcs11_inspect</tt> command.</p>
<pre style="padding-left: 30px;">$ pkcs11_inspect
RYAN.LANE</pre>
<p>Before we modify PAM, we should ensure we can access the smart card, and map CNs to user names. Using the <tt>pklogin_finder</tt> command, we can both test access to the smart card, and whether the mapping is working properly. The output of the command should return the user name. If it returns nothing, the mapping module probably isn&#8217;t mapping the user properly. For more detailed information, you can run &#8220;<tt>pklogin_finder debug</tt>&#8220;; as a warning, running this command with debug will print your pin to the screen.</p>
<pre style="padding-left: 30px;">$ pklogin_finder
laner</pre>
<pre style="padding-left: 30px;">$ pklogin_finder debug
DEBUG:pam_config.c:188: Using config file /etc/pam_pkcs11/pam_pkcs11.conf
DEBUG:pkcs11.c:65: Initializing NSS ...
DEBUG:pkcs11.c:75: Initializing NSS ... database=/etc/pki/nssdb
DEBUG:pkcs11.c:89: ...  NSS Complete
DEBUG:pklogin_finder.c:67: loading pkcs #11 module...
DEBUG:pkcs11.c:101: Looking up module in list
DEBUG:pkcs11.c:104: modList = 0x8b1ad50 next = 0x8b2a870
DEBUG:pkcs11.c:105: dllName= &lt;null&gt;
DEBUG:pkcs11.c:104: modList = 0x8b2a870 next = 0x0
DEBUG:pkcs11.c:105: dllName= /usr/lib/libcoolkeypk11.so
DEBUG:pklogin_finder.c:75: initialising pkcs #11 module...
DEBUG:pklogin_finder.c:87: no token available</pre>
<p>Notice the above debug output is telling me that I don&#8217;t have a smart card inserted&#8230;</p>
<h2>Configuring PAM</h2>
<p>The only file we need to configure for smart card login is <tt>/etc/pam.d/system-auth</tt>; your file should look something like this:</p>
<pre style="padding-left: 30px;">auth        required      pam_env.so
auth        [success=1 default=ignore] pam_succeed_if.so service notin login:gdm:xdm:kdm:xscreensaver:gnome-screensaver:kscreensaver quiet use_uid
auth        [success=done authinfo_unavail=ignore ignore=ignore default=die] pam_pkcs11.so
auth        sufficient    pam_unix.so likeauth
auth        required      pam_deny.so

account     required      pam_unix.so broken_shadow
account     sufficient    pam_localuser.so
account     required      pam_permit.so

password    optional      pam_pkcs11.so
password    requisite     pam_cracklib.so retry=3 dcredit=-2 ucredit=-2 ocredit=-2 lcredit=-2 minlen=10
password    sufficient    pam_unix.so md5 shadow try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so</pre>
<p>Notice that the important lines are:</p>
<pre style="padding-left: 30px;">auth        [success=1 default=ignore] pam_succeed_if.so service notin login:gdm:xdm:kdm:xscreensaver:gnome-screensaver:kscreensaver quiet use_uid</pre>
<p>This tells PAM that pam_pkcs11 should only be used if it is in one of the following services: <tt>login:gdm:xdm:kdm:xscreensaver:gnome-screensaver:kscreensaver</tt>. This ensures that the smartcard won&#8217;t be accessed if someone logs in via a service like SSH, or FTP, where smartcard login doesn&#8217;t make sense.</p>
<pre style="padding-left: 30px;">auth        [success=done authinfo_unavail=ignore ignore=ignore default=die] pam_pkcs11.so</pre>
<p>This tells PAM to succeed if pam_pkcs11 logs the user in, and maps their user name properly, but to ignore the module otherwise. In this case, regular unix password authentication is still allowed. If you wish to disallow password authentication, you should set <tt>authinfo_unavail</tt> and <tt>ignore</tt> to <tt>die</tt>.</p>
<pre style="padding-left: 30px;">password    optional      pam_pkcs11.so</pre>
<p>This optionally allows PAM to reset the password/pin on the smartcard. This line isn&#8217;t likely needed, and you can leave it out if you wish.</p>
<p>After saving the file, you should test your PAM configuration before logging out. You can do so by going to a virtual console, and logging in. Do the following:</p>
<ol>
<li>Insert your smart card</li>
<li>At the Username prompt, hit the spacebar once and hit enter</li>
<li>Type in your PIN when requested
<ul>
<li>If you are using the number pad, make sure num lock is on!</li>
</ul>
</li>
</ol>
<h2>Conclusion and next part in the series</h2>
<p>With this, you should be able to log users into a system using a smartcard. In the next part of this series, I&#8217;ll discuss how to add pam_krb5 into the mix to automatically get a Kerberos ticket from an Active Directory domain using PKINIT.</p>
<p><strong>Update 12/08/08:</strong> Removed the stuff about pointing explicitly to the coolkey module. I tested this recently, and it was working fine without (for the first time). Pointing to the module explicitly definitely causes issues with 64-bit RHEL. Maybe Red Hat fixed this in a later release?</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;submitHeadline=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+2%29+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F24%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/using-nss-with-openssh-for-smart-card-login/' rel='bookmark' title='Permanent Link: Using NSS with OpenSSH for Smart Card Login'>Using NSS with OpenSSH for Smart Card Login</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/qBkVbyL5nZI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/</feedburner:origLink></item>
		<item>
		<title>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 1)</title>
		<link>http://feedproxy.google.com/~r/RyanLanesBlog_pki/~3/WD29ED5TtPA/</link>
		<comments>http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 14:01:57 +0000</pubDate>
		<dc:creator>Ryan Lane</dc:creator>
				<category><![CDATA[LDAP]]></category>
		<category><![CDATA[pki]]></category>

		<guid isPermaLink="false">http://ryandlane.com/wprdl/?p=9</guid>
		<description><![CDATA[Starting with Red Hat Enterprise Linux version 5 (RHEL 5), Red Hat added native support for PKI with pam_pkcs11, NSS, ccid, coolkey, and pcsc-lite. RHEL 5 also added rudimentary support for PKINIT in their Kerberos client, mostly based upon the CITI and Heimdal implementation (in pkinit-nss). Coming in a future update to RHEL 5 (maybe [...]


Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/' rel='bookmark' title='Permanent Link: SSL replication and CA trusts in Sun Directory Server 6.x'>SSL replication and CA trusts in Sun Directory Server 6.x</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Starting with Red Hat Enterprise Linux version 5 (RHEL 5), Red Hat added native support for PKI with pam_pkcs11, NSS, ccid, coolkey, and pcsc-lite. RHEL 5 also added rudimentary support for PKINIT in their Kerberos client, mostly based upon the CITI and Heimdal implementation (in pkinit-nss). Coming in a future update to RHEL 5 (maybe 5.3 or 5.4) you can expect better PKINIT support, with more MIT based PKINIT support.</p>
<p>This series of articles will cover how to configure a RHEL 5 system to allow users to log in with a smartcard, while also getting a Kerberos ticket from an Active Directory domain.</p>
<p>Part 1 will cover configuring NSS and OpenSSL. <a href="http://ryandlane.com/wprdl/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/">Part 2</a> will cover configuring pam_pkcs11 and testing a smartcard using the centralized NSS database. Part 3 will cover configuring Kerberos, PKINIT, and pam_krb5.</p>
<p>For the sake of simplicity, we are using our own Certificate Authority (CA), and not a third party. We will have only one root CA, and two intermediate CAs. All of the CA certificates are assumed to be in <tt>/root</tt>/CAs. All certificates are assumed to be in ascii (pem) format.</p>
<p>So, on with part 1&#8230;<br />
</p>
<h2>Configuring NSS and OpenSSL</h2>
<p>Red Hat seems to be mostly moving away from using OpenSSL, and is now using NSS as their main crypto library; unfortunately, a lot of applications still use OpenSSL pretty heavily, so we&#8217;ll have to configure both NSS and OpenSSL. Thankfully, Red Hat centralized their PKI content into a centralized location: <tt>/etc/pki</tt>; this directory holds content for both OpenSSL and NSS.</p>
<h3>Adding CA certs</h3>
<p>Red Hat&#8217;s centralized NSS database holds no trusts by default. From a system security point of view, this is a good thing because PKI login will be limited only to the specific CAs that you trust. We&#8217;ll use certutil to add the CA certs to the central database in <tt>/etc/pki/nssdb:</tt></p>
<pre style="padding-left: 30px;">certutil -A -n "Example Corp Root" -t "CT,C,C" -a -d /etc/pki/nssdb -i /root/CAs/examplecorprootclass2.crt</pre>
<p>Let&#8217;s break down this command: &#8220;-A&#8221; tells certutil we want to add a certificate to the database. &#8220;-n&#8221; is used to give an alias to the certificate. &#8220;-t&#8221; tells certutil how to trust the certificate; this example may be overkill depending on how your CA is going to be used. You should normally only trust a certificate as much as actually needed. &#8220;-a&#8221; tells certutil the certificate we are adding is in ascii (pem) format. &#8220;-d&#8221; tells certutil what database we wish to add the certificate to. &#8220;-i&#8221; lists the certificate we wish to add.</p>
<p>You should repeat this command for every CA you have, changing the alias, trust level, and input file appropriately. To get an idea of the trust levels available, run the following:</p>
<pre style="padding-left: 30px;">certutil -H</pre>
<p>To see a list of installed certificates run:</p>
<pre style="padding-left: 30px;">certutil -L -d /etc/pki/nssdb</pre>
<p>Adding certificates to OpenSSL is easier. We&#8217;ll do three things:</p>
<ol>
<li>Drop the certificates into the /etc/pki/tls/certs directory
<ul>
<li>
<pre>cp /root/CAs/*.crt /etc/pki/tls/certs</pre>
</li>
</ul>
</li>
<li>Make hash links of the certificates
<ul>
<li>
<pre>pushd /etc/pki/tls/certs; for i in `ls *.crt`; do [ ! -e $i.0 ] &amp;&amp; ln -s $i $(openssl x509 -hash -noout -in $i).0; done; popd</pre>
</li>
</ul>
</li>
<li>Make a bundle of the certificates
<ul>
<li>
<pre>cat /root/CAs/*.crt &gt; /etc/pki/tls/examplecom-bundle.crt</pre>
</li>
</ul>
</li>
</ol>
<h3>Check to ensure your smartcard library is in the NSS secmod database</h3>
<p>For your system to access your smartcard, it&#8217;ll need to use a library to access it. Your NSS database may already have the library loaded as a module, but it is important to check. To check the loaded modules in NSS, use the <strong>modutil</strong> command:</p>
<pre style="padding-left: 30px;">modutil -list -dbdir /etc/pki/nssdb
<em>Listing of PKCS #11 Modules
-----------------------------------------------------------
 1. NSS Internal PKCS #11 Module
 slots: 2 slots attached
 status: loaded

 slot: NSS Internal Cryptographic Services                            
 token: NSS Generic Crypto Services

 slot: NSS User Private Key and Certificate Services                  
 token: NSS Certificate DB

 2. CoolKey PKCS #11 Module
 library name: libcoolkeypk11.so
 slots: 1 slot attached
 status: loaded

 slot: E-Gate 0 0
 token:
-----------------------------------------------------------</em></pre>
<p>Notice above that the &#8220;NSS Internal PKCS#11 Module&#8221; and the &#8220;CoolKey PKCS #11 Module&#8221; modules are loaded. The NSS internal module is always loaded in NSS databases; the important module here is the CoolKey one. If a smartcard module isn&#8217;t loaded, you can load one with the <strong>modutil</strong> command:</p>
<pre style="padding-left: 30px;">modutil -add "CoolKey PKCS #11 Module" -libfile libcoolkeypk11.so -dbdir /etc/pki/nssdb</pre>
<p>You can use the full path to the library if you wish, but it isn&#8217;t necessary; furthermore, if you are scripting this, it&#8217;ll cause issues between different platforms.</p>
<p>This covers configuring NSS and OpenSSL; the <a href="http://ryandlane.com/wprdl/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/">next part</a> in this series of articles will focus on pam_pkcs11.</p>
<p><strong>Update (07/09/2009):</strong> Added information about checking NSS for smartcard libraries</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share:</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;submitHeadline=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;LinkedIn"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/linkedin.png" title="Add to&nbsp;LinkedIn" alt="Add to&nbsp;LinkedIn" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F&amp;title=Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Seamless+Smartcard+login+with+pam_pkcs11%2C+and+pam_krb5+against+an+Active+Directory+Domain+using+Red+Hat+Enterprise+Linux+5+%28Part+1%29+@+http%3A%2F%2Fryandlane.com%2Fblog%2F2008%2F10%2F21%2Fseamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://ryandlane.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://ryandlane.com/blog/2008/10/24/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-2/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 2)</a></li>
<li><a href='http://ryandlane.com/blog/2008/12/08/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-3/' rel='bookmark' title='Permanent Link: Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)'>Seamless Smartcard login with pam_pkcs11, and pam_krb5 against an Active Directory Domain using Red Hat Enterprise Linux 5 (Part 3)</a></li>
<li><a href='http://ryandlane.com/blog/2009/06/19/ssl-replication-and-ca-trusts-in-sun-directory-server-6-x/' rel='bookmark' title='Permanent Link: SSL replication and CA trusts in Sun Directory Server 6.x'>SSL replication and CA trusts in Sun Directory Server 6.x</a></li>
</ol></p><img src="http://feeds.feedburner.com/~r/RyanLanesBlog_pki/~4/WD29ED5TtPA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://ryandlane.com/blog/2008/10/21/seamless-smartcard-login-with-pam_pkcs11-and-pam_krb5-against-an-active-directory-domain-using-red-hat-enterprise-linux-5-part-1/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 116/300 queries in 1.993 seconds using memcached
Object Caching 0/0 objects using memcached

Served from: ryandlane.com @ 2010-07-29 13:56:52 -->
