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

<channel>
	<title>ssh &#8211; privacyID3A</title>
	<atom:link href="https://www.privacyidea.org/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.privacyidea.org</link>
	<description>flexible, Open Source Multi Factor Authentication (2FA)</description>
	<lastBuildDate>Wed, 08 Mar 2017 12:03:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.privacyidea.org/wp-content/uploads/2016/06/cropped-only-logo-white-background-32x32.png</url>
	<title>ssh &#8211; privacyID3A</title>
	<link>https://www.privacyidea.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SSH Keys and OTP: Really strong two factor authentication</title>
		<link>https://www.privacyidea.org/ssh-keys-and-otp-really-strong-two-factor-authentication/</link>
					<comments>https://www.privacyidea.org/ssh-keys-and-otp-really-strong-two-factor-authentication/#comments</comments>
		
		<dc:creator><![CDATA[Cornelius Kölbel]]></dc:creator>
		<pubDate>Thu, 29 Oct 2015 11:00:29 +0000</pubDate>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Yubikey]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=771</guid>

					<description><![CDATA[This blog will show how you can use privacyIDEA to secure your SSH login. In this case users need to provide an SSH Key and in addition an OTP token and an optional password. Thus you have the following authentication factors: SSH Key (soft possession factor &#8211; copyable!) optional passphrase on the SSH Key, which is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This blog will show how you can use privacyIDEA to secure your SSH login. In this case users need to provide an SSH Key and in addition an OTP token and an optional password.</p>
<p>Thus you have the following authentication factors:</p>
<ol>
<li>SSH Key (soft <strong>possession</strong> factor &#8211; copyable!)</li>
<li>optional passphrase on the SSH Key, which is not controlled by the server! (<strong>knowledge</strong>)</li>
<li>OTP token <a href="http://privacyidea.readthedocs.org/en/latest/configuration/token_config.html#supported-tokentypes" target="_blank">supported by privacyIDEA</a> like Google Authenticator or preferable a Yubikey (hard <strong>possession</strong> factor &#8211; not copyable)</li>
<li>an optional OTP PIN controlled by privacyIDEA (<strong>knowledge</strong>)</li>
</ol>
<h2>Connect SSH to privacyIDEA</h2>
<p>Connecting SSH to privacyIDEA is described in this <a href="https://www.youtube.com/watch?v=tNoHzrajtcg&amp;t=1m52s" target="_blank">video</a>. It uses the privacyIDEA PAM Module in the <a href="http://privacyidea.readthedocs.org/en/latest/application_plugins/index.html#pluggable-authentication-module">online documentation</a>.</p>
<p>In the SSH configuration you need to set</p>
<pre>UsePAM yes</pre>
<p>This way SSH will authenticate the user against the PAM stack using <em>/etc/pam.d/sshd</em>.</p>
<p>This howto will assume you are using a Ubuntu system. Other systems like CentOS use slightly different PAM configuration, but the idea is the same.</p>
<h3>Install privacyIDEA PAM</h3>
<p>To use PAM with privacyIDEA you need the privacyIDEA <a href="https://github.com/privacyidea/pam_python">PAM authentication module</a>. On a Ubuntu 14.04 you can install it like</p>
<pre>add-apt-repository ppa:privacyidea/privacyidea
apt-get update
apt-get install privacyidea-pam</pre>
<p>In other cases you can get it from github with the above mentioned link.</p>
<h3>Configure SSH PAM</h3>
<p>Now lets take a look at the PAM config for SSH. The file <em>/etc/pam.d/sshd</em> contains a line</p>
<pre>@include common-auth</pre>
<p>Change this line to</p>
<pre>@include common-auth-pi</pre>
<p>By creating such a new file it is easier for us to add two factors to every PAM enabled service.</p>
<p>Copy the file <em>/etc/pam.d/common-auth</em> to <em>/etc/pam.d/common-auth-pi</em>. The file<em> /etc/pam.d/common-auth-pi</em> will look like this:</p>
<pre>auth     [success=1 default=ignore] pam_python.so /lib/security/privacyidea_pam.py url=https://yourserver \ 
                                                  nosslverify debug
auth    requisite   pam_deny.so
auth    required    pam_permit.so
auth    optional    pam_cap.so</pre>
<p>In the file <em>common-auth-pi</em> we replace <em>pam_unix.so</em> with <em>privacyidea_pam</em>. You need to specify the URL of your privacyIDEA server. If everything is working out fine, you can remove the <em>debug</em> parameter. If you have a trusted certificate you can remove <em>nosslverify</em>.</p>
<blockquote><p>Please assure, that you are logged in to your system or that you have other mean to login like ssh keys. Modifying the PAM stack for SSH can result in not being able to login with a password via SSH anymore.</p></blockquote>
<p>Now that you have configured</p>
<ul>
<li>/etc/ssh/sshd_config</li>
<li>/etc/pam.d/common-auth-pi</li>
<li>/etc/pam.d/sshd</li>
</ul>
<p>you can restart the SSH server for the changes to take effect.</p>
<p>When you now try to login via SSH, the username and password will be sent to privacyIDEA for verification. You can not use you OTP PIN and Yubikey to login.</p>
<blockquote><p>If you experience any problems, take a look at <em>/var/log/auth.log</em>.</p></blockquote>
<p>If everything is working fine, you are now authenticating with:</p>
<ol>
<li>OTP token <a href="http://privacyidea.readthedocs.org/en/latest/configuration/token_config.html#supported-tokentypes" target="_blank">supported by privacyIDEA</a> like Google Authenticator or preferable a Yubikey (hard <strong>possession</strong> factor &#8211; not copyable)</li>
<li>an optional OTP PIN controlled by privacyIDEA (<strong>knowledge</strong>)</li>
</ol>
<h2>Add SSH Keys</h2>
<p>You may realize, that if you have an SSH key in the authorized_keys you will not be asked for the OTP. At the moment you either login with SSH key or with OTP. Let&#8217;s change this now, that you can use SSH key <strong>and</strong> OTP.</p>
<p>The current OpenSSH comes with the options <strong>AuthenticationMethods</strong>. This is used to concatenate required authentication methods. See the man page of sshd_config for more details.</p>
<p>In the file<em> /etc/ssh/sshd_config</em> we add this line:</p>
<pre>AuthenticationMethods publickey,password</pre>
<p>This means that SSH will require that you pass a trusted SSH key and after this ask you for a password (PIN+OTP), which will be verified by privacyIDEA.</p>
<p>The login will look like this:</p>
<pre>root@gawain ~ # ssh root@privacyidea
Authenticated with partial success.
root@privacyidea's password: 
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-66-generic x86_64)</pre>
<p>The &#8220;Authenticated with partial success&#8221; means, that the authentication with the SSH key succeeded. Now you need to specify the One Time Password to be sent to privacyIDEA.</p>
<blockquote><p>Note: If you want to login as user &#8220;root&#8221;, be sure to add &#8220;PermitRootLogin yes&#8221; to your<em> sshd_config</em>.</p></blockquote>
<p>Finally we managed to authenticate the users with:</p>
<ol>
<li>SSH Key (soft <strong>possession</strong> factor &#8211; copyable!)</li>
<li>optional passphrase on the SSH Key, which is not controlled by the server! (<strong>knowledge</strong>)</li>
<li>OTP token <a href="http://privacyidea.readthedocs.org/en/latest/configuration/token_config.html#supported-tokentypes" target="_blank">supported by privacyIDEA</a> like Google Authenticator or preferable a Yubikey (hard <strong>possession</strong> factor &#8211; not copyable)</li>
<li>an optional OTP PIN controlled by privacyIDEA (<strong>knowledge</strong>)</li>
</ol>
<h2>Manage SSH Keys with privacyIDEA</h2>
<p>Wait! Are you still there? One thing might still strike you:</p>
<p>While all OTP tokens are centrally managed by privacyIDEA, users still put their public SSH keys on all the machines and you are wondering where the SSH keys of all the users are floating around.</p>
<p>There is no easy way for you to revoke a compromized SSH key.</p>
<p>But you can also solve this with privacyIDEA. Users can upload their public SSH keys to privacyIDEA with the tokentype <a href="http://privacyidea.readthedocs.org/en/latest/configuration/tokens/sshkey.html" target="_blank">SSH Key</a>.</p>
<p>This way you can also manage all SSH keys in privacyIDEA. In sshd_config you need to use the AuthorizedKeysCommand to retrieve the SSH keys from privayyIDEA just in time. Deleting an SSH key in privacyIDEA will deny access for this user immediatly.</p>
<p>You can read <a href="https://www.howtoforge.com/tutorial/ssh-key-management-with-privacyidea/" target="_blank">SSH Key Management with privacyIDEA</a> to set this up.</p>
<p>This way you have three strong factors to secure the access to SSH.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.privacyidea.org/ssh-keys-and-otp-really-strong-two-factor-authentication/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
