<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"><channel><title>civilfritz.net (Posts about hpc)</title><link>https://civilfritz.net/</link><description></description><atom:link href="https://civilfritz.net/tags/hpc.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:janderson@civilfritz.net"&gt;Jonathon Anderson&lt;/a&gt; &lt;a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"&gt;&lt;img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /&gt;&lt;/a&gt;</copyright><lastBuildDate>Sun, 24 Mar 2024 06:48:50 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>User-selectable authentication methods using pam_authtok</title><link>https://civilfritz.net/curc/user-selectable-authentication-methods-using-pam-authtok/</link><dc:creator>Jonathon Anderson</dc:creator><description>&lt;p&gt;Research Computing is in the process of migrating and expanding our
authentication system to support additional authentication methods.
Historically we’ve supported &lt;a class="reference external" href="https://www.vasco.com/products/management-platforms/"&gt;VASCO
IDENTIKEY&lt;/a&gt;
time-based one-time-password and pin to provide two-factor
authentication.&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ ssh user1234@login.rc.colorado.edu
user1234@login.rc.colorado.edu's password: &amp;lt;pin&amp;gt;&amp;lt;otp&amp;gt;

[user1234@login04 ~]$&lt;/pre&gt;
&lt;p&gt;But the VASCO tokens are expensive, get lost or left at home, have a
battery that runs out, and have an internal clock that sometimes falls
out-of-sync with the rest of the authentication system. For these and
other reasons we’re provisioning most new account with
&lt;a class="reference external" href="http://www.duosecurity.com"&gt;Duo&lt;/a&gt;, which provides iOS and Android
apps but also supports SMS and voice calls.&lt;/p&gt;
&lt;p&gt;Unlike VASCO, Duo is only a single authentication factor; so we’ve also
added support for upstream CU-Boulder campus password authentication to
be used in tandem.&lt;/p&gt;
&lt;p&gt;This means that we have to support both authentication mechanisms–VASCO
and password+Duo–simultaneously. A naïve implementation might just stack
these methods together.&lt;/p&gt;
&lt;pre class="literal-block"&gt;auth sufficient pam_radius_auth.so try_first_pass # VASCO authenticates over RADIUS
auth requisite  pam_krb5.so try_first_pass # CU-Boulder campus password
auth required   pam_duo.so&lt;/pre&gt;
&lt;p&gt;This generally works: VASCO authentication is attempted first over
RADIUS. If that fails, authentication is attempted against the campus
password and, if that succeeds, against Duo.&lt;/p&gt;
&lt;p&gt;Unfortunately, this generates spurious authentication failures in VASCO
when using Duo to authenticate: the VASCO method fails, &lt;em&gt;then&lt;/em&gt; Duo
authentication is attempted. Users who have &lt;em&gt;both&lt;/em&gt; VASCO &lt;em&gt;and&lt;/em&gt; Duo
accounts (e.g., all administrators) may generate enough failures to
trigger the break-in mitigation security system, and the VASCO account
may be disabled. This same issue exists if we reverse the authentication
order to try Duo first, &lt;em&gt;then&lt;/em&gt; VASCO: VASCO users might then cause their
campus passwords to become disabled.&lt;/p&gt;
&lt;p&gt;In stead, we need to enable users to explicitly specify which
authentication method they’re using.&lt;/p&gt;
&lt;section id="separate-sssd-domains"&gt;
&lt;h2&gt;Separate sssd domains&lt;/h2&gt;
&lt;p&gt;Our first attempt to provide explicit access to different authentication
methods was to provide multiple redundant
&lt;a class="reference external" href="https://fedorahosted.org/sssd/"&gt;sssd&lt;/a&gt; domains.&lt;/p&gt;
&lt;pre class="literal-block"&gt;[domain/rc]
description = Research Computing
proxy_pam_target = curc-twofactor-vasco


[domain/duo]
description = Research Computing (identikey+duo authentication)
enumerate = false
proxy_pam_target = curc-twofactor-duo&lt;/pre&gt;
&lt;p&gt;This allows users to log in normally using VASCO, while password+Duo
authentication can be requested explicitly by logging in as
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;${user}@duo&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ ssh -l user1234@duo login.rc.colorado.edu&lt;/pre&gt;
&lt;p&gt;This works well enough for the common case of shell access over SSH:
login is permitted and, since both the default &lt;code class="docutils literal"&gt;rc&lt;/code&gt; domain and the
&lt;code class="docutils literal"&gt;duo&lt;/code&gt; alias domain are both backed by the same LDAP directory, NSS
sees no important difference once a user is logged in using either
method.&lt;/p&gt;
&lt;p&gt;This works because POSIX systems store the uid number returned by
&lt;a class="reference external" href="http://www.linux-pam.org"&gt;PAM&lt;/a&gt; and
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Name_Service_Switch"&gt;NSS&lt;/a&gt;, and
generally resolve the uid number to the username on-demand. Not all
systems work this way, however. For example, when we attempted to use
this authentication mechanism to authenticate to our prototype
&lt;a class="reference external" href="https://jupyterhub.readthedocs.io/"&gt;JupyterHub&lt;/a&gt; (web) service, jobs
dispatched to &lt;a class="reference external" href="http://slurm.schedmd.com"&gt;Slurm&lt;/a&gt; retained the
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;${user}@duo&lt;/span&gt;&lt;/code&gt; username format. Slurm &lt;em&gt;also&lt;/em&gt; uses usernames internally,
and the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;${user}@duo&lt;/span&gt;&lt;/code&gt; username is not populated within Slurm: only the
base &lt;code class="docutils literal"&gt;${user}&lt;/code&gt; username.&lt;/p&gt;
&lt;p&gt;Expecting that we would continue to find more unexpected side-effects of
this implementation, we started to look for an alternative mechanism
that doesn’t modify the specified username.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="pam-authtok"&gt;
&lt;h2&gt;pam_authtok&lt;/h2&gt;
&lt;p&gt;In general, a user provides two pieces of information during
authentication: a username (which we’ve already determined we shouldn’t
modify) and an authentication token or password. We &lt;em&gt;should&lt;/em&gt; be able to
detect, for example, a prefix to that authentication token to determine
what authentication method to use.&lt;/p&gt;
&lt;pre class="literal-block"&gt;$ ssh user1234@login.rc.colorado.edu
user1234@login.rc.colorado.edu's password: duo:&amp;lt;password&amp;gt;

[user1234@login04 ~]$&lt;/pre&gt;
&lt;p&gt;But we found no such pam module that would allow us to manipulate the
authentication token… so &lt;a class="reference external" href="https://github.com/ResearchComputing/pam_authtok"&gt;we wrote
one&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="literal-block"&gt;auth [success=1 default=ignore] pam_authtok.so prefix=duo: strip prompt=password:

auth [success=done new_authtok_reqd=done default=die] pam_radius_auth.so try_first_pass

auth requisite pam_krb5.so try_first_pass
auth [success=done new_authtok_reqd=done default=die] pam_duo.so&lt;/pre&gt;
&lt;p&gt;Now our PAM stack authenticates against VASCO by default; but, if the
user provides a password with a &lt;code class="docutils literal"&gt;duo:&lt;/code&gt; prefix, authentication skips
VASCO and authenticates the supplied password, followed by Duo push. Our
actual production PAM stack is a bit more complicated, supporting a
redundant &lt;code class="docutils literal"&gt;vasco:&lt;/code&gt; prefix as well, for forward-compatibility should we
change the default authentication mechanism in the future. We can also
extend this mechanism to add arbitrary additional authentication
mechanisms in the future.&lt;/p&gt;
&lt;/section&gt;</description><category>hpc</category><category>technology</category><guid>https://civilfritz.net/curc/user-selectable-authentication-methods-using-pam-authtok/</guid><pubDate>Mon, 16 May 2016 11:37:00 GMT</pubDate></item></channel></rss>