<p style="text-align: center;"><strong><span style="font-size:24px;"><span style="font-family: lucida sans unicode,lucida grande,sans-serif;">Connexion à 2 facteurs en SSH</span></span></strong></p><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Dans un soucis de sécurité permanent, l'authentification à 2 facteurs vient <strong>renforcer la sécurité de votre machine </strong>en ajoutant, en plus de votre mot de passe, un <strong>code sur 6 chiffres généré toutes les 30 secondes</strong>. Ainsi, un pirate ayant eu connaissance de votre mot de passe ne pourra se connecter que s'il connait le code de sécurité.</span></p><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><span style="font-size:18px;"><strong>Installation et configuration sur la machine :</strong></span></span></p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><hr/></span></p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Tout d'abord installer le paquet</span><span style="font-family:courier new,courier,monospace;"> <strong>libpam-google-authenticator</strong></span><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"> :</span></p><pre class="html ipsCode prettyprint" data-pbcklang="html" data-pbcktabsize="4">sudo apt-get install libpam-google-authenticator</pre><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Ensuite vous devez <strong>générer une clé d'authentification</strong> qui servira pour l'application qui générera le code secret :</span></p><pre class="html ipsCode prettyprint" data-pbcklang="html" data-pbcktabsize="4">google-authenticator</pre><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Suivez les instructions et sauvegardez dans un coin les clés de secours</strong> (car si vous n'avez plus accès à votre application, il vous sera alors impossible de vous connecter à votre serveur).</span></p><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Ajoutez la ligne suivante au fichier <strong>/etc/pam.d/sshd</strong> :</span></p><pre class="html ipsCode prettyprint" data-pbcklang="html" data-pbcktabsize="4">auth required pam_google_authenticator.so</pre><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Cherchez l'attribut suivant <strong>/etc/ssh/sshd_config </strong>dans le fichier et modifiez sa valeur comme ci-dessous :</span></p><pre class="html ipsCode prettyprint" data-pbcklang="html" data-pbcktabsize="4">ChallengeResponseAuthentication yes</pre><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Redémarrez le service <strong>ssh </strong>:</span></p><pre class="html ipsCode prettyprint" data-pbcklang="html" data-pbcktabsize="4">sudo service ssh restart</pre><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Votre machine est prête, il ne vous reste plus qu'à configurer votre application.</span></p><p> </p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><span style="font-size:18px;"><strong>Sur votre application OTP :</strong></span></span></p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><hr/></span></p><p><span style="font-family:lucida sans unicode,lucida grande,sans-serif;">Ajoutez une nouvelle clé avec la configuration qui suit :</span></p><ul><li><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Secret :</strong> la clé secrète générée avec le terminal</span></li><li><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Type :</strong> TOTP</span></li><li><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Digits :</strong> 6</span></li><li><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Algorithm : </strong>SHA512</span></li><li><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><strong>Interval : </strong>30</span></li></ul>