Outils pour utilisateurs

Outils du site


linux:ssh_gauth

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
linux:ssh_gauth [2016/02/20 23:22] gdureuillinux:ssh_gauth [2020/07/24 22:03] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 ====== Sécuriser les connexions SSH avec Google Authenticator ====== ====== Sécuriser les connexions SSH avec Google Authenticator ======
  
-Testé sur Debian 8+===== Information ===== 
 + 
 +<WRAP center info 100%> 
 +Testé sur Debian 8
 +</WRAP>
  
 ===== Installation ===== ===== Installation =====
  
-Installer les packages pour compiler les outils nécessaires +Installer les packages.
- +
-<code> +
-apt-get install build-essential make automake m4 autotools-dev libtool libpam0g-dev libpam0g unzip qrencode +
-</code> +
- +
-(Ici unzip sert à décompresser l'archive, qrencode sert à générer le QR pour configurer l'application mobile plus facilementLe reste sert à la compilation.) +
- +
-Télécharger et décompresser les sources de libpam authenticator sur Github (voir lien "Source 3" en bas de page) +
- +
-<code> +
-cd /usr/local/src +
-wget https://github.com/google/google-authenticator/archive/master.zip -O googleauth.zip +
-unzip googleauth.zip && rm googleauth.zip +
-cd google-authenticator-master/libpam +
-</code> +
- +
-Penser à adapter l'URL pour la dernière version et donc le nom du dossier qui est extrait +
- +
-Lancer la compilation+
  
-<code+<sxh bash;
-./bootstrap.sh +apt install libpam-google-authenticator qrencode 
-./configure +</sxh>
-make +
-make install +
-</code>+
  
 ===== Configuration ===== ===== Configuration =====
Ligne 41: Ligne 23:
 Saisir la commande Saisir la commande
  
-<code>+<sxh bash;>
 google-authenticator google-authenticator
-</code>+</sxh>
  
 Cinq questions vont être posées, les réponses YES sont les plus sécurisées, à adapter à vos besoins Cinq questions vont être posées, les réponses YES sont les plus sécurisées, à adapter à vos besoins
  
-<code>+<sxh text;>
 Do you want authentication tokens to be time-based (y/n) Do you want authentication tokens to be time-based (y/n)
      
 Yes Yes
-</code>+</sxh>
  
 Vous obtenez une adresse de QRCode ou une clé de configuration pour Google Authenticator sur votre mobile. Gardez aussi en sécurité les 5 codes de secours. Vous obtenez une adresse de QRCode ou une clé de configuration pour Google Authenticator sur votre mobile. Gardez aussi en sécurité les 5 codes de secours.
  
-<code>+<sxh text;>
 Do you want me to update your "/root/.google_authenticator" file (y/n) Do you want me to update your "/root/.google_authenticator" file (y/n)
      
 Yes Yes
-</code>+</sxh>
  
 Le fichier sera généré pour l'utilisateur courant SEULEMENT ! Le fichier sera généré pour l'utilisateur courant SEULEMENT !
  
-<code>+<sxh text;>
 Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n) Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n)
      
 Yes Yes
-</code>+</sxh>
  
-<code>+<sxh text;>
 By default, tokens are good for 30 seconds and in order to compensate for possible time-skew between the client and the server, we allow an extra token before and after the current time. If you experience problems with poor time synchronization, you can increase the window from its default size of 1:30min to about 4min. Do you want to do so (y/n) By default, tokens are good for 30 seconds and in order to compensate for possible time-skew between the client and the server, we allow an extra token before and after the current time. If you experience problems with poor time synchronization, you can increase the window from its default size of 1:30min to about 4min. Do you want to do so (y/n)
      
 Yes Yes
-</code>+</sxh>
  
-<code>+<sxh text;>
 If the computer that you are logging into isn't hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. Do you want to enable rate-limiting (y/n) If the computer that you are logging into isn't hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. Do you want to enable rate-limiting (y/n)
      
 Yes Yes
-</code>+</sxh>
  
 Un QR sera affiché, et/ou une clé secrète, pour configurer votre Google Authenticator. Un QR sera affiché, et/ou une clé secrète, pour configurer votre Google Authenticator.
Ligne 87: Ligne 69:
 Editer le fichier de configuration PAM Editer le fichier de configuration PAM
  
-<code+<sxh bash;
-/etc/pam.d/sshd +nano /etc/pam.d/sshd 
-</code>+</sxh>
  
 Ajouter à la fin Ajouter à la fin
  
-<code>+<sxh text; Title: /etc/pam.d/sshd>
 auth required pam_google_authenticator.so nullok auth required pam_google_authenticator.so nullok
-</code>+</sxh>
  
 Le paramètre nullok permet à un compte utilisateur, sans configuration de double authentification de se connecter normalement en SSH. Enlever nullok pour forcer la double authentification sur TOUT les comptes. Le paramètre nullok permet à un compte utilisateur, sans configuration de double authentification de se connecter normalement en SSH. Enlever nullok pour forcer la double authentification sur TOUT les comptes.
Ligne 103: Ligne 85:
 Editer le fichier suivant Editer le fichier suivant
  
-<code+<sxh bash;
-/etc/ssh/sshd_config +nano /etc/ssh/sshd_config 
-</code>+</sxh>
  
-Chercher "ChallengeResponseAuthenticationet replacer "nopar "yes"+Chercher ''ChallengeResponseAuthentication'' et replacer ''no'' par ''yes''
  
 Redémarrer le service ssh Redémarrer le service ssh
  
-<code>+<sxh bash;>
 /etc/init.d/ssh restart /etc/init.d/ssh restart
-</code>+</sxh>
  
 ===== Tester la connexion ===== ===== Tester la connexion =====
  
-Vérifier la configuration dans <code>/root/.google_authenticator</code> ou "/home/user/.google_authenticator"+Vérifier la configuration dans ''/root/.google_authenticator'' ou ''/home/user/.google_authenticator''
  
 Tester la connexion en SSH. Tester la connexion en SSH.
  
-Si problème, vérifier "/var/log/auth.log".+Si problème, vérifier ''/var/log/auth.log''. 
 + 
 +===== Restreindre à une liste d'utilisateurs ===== 
 + 
 +On peut restreindre l'accès à SSH à une liste d'utilisateurs. 
 + 
 +<sxh bash;> 
 +nano /etc/ssh/sshd_config 
 +</sxh> 
 + 
 +Et ajouter : 
 +<sxh text; Title: /etc/ssh/sshd_config> 
 +AllowUsers root mon_user_1 mon_user_2 
 +</sxh> 
 + 
 +===== Sources =====
  
-[[http://pirmax.fr/2014/02/13/securiser-les-connexions-ssh-avec-google-authenticator/|Source 1]] - [[http://www.linux.org/threads/google-authenticator-for-ssh.4590/|Source 2]] - [[https://github.com/google/google-authenticator|Source 3]]+[[https://github.com/google/google-authenticator|github.com/google/google-authenticator]] - [[https://korben.info/activer-lauthentification-2-etapes-serveur-ssh.html|korben.info]] - [[https://www.rosehosting.com/blog/secure-your-ssh-using-two-factor-authentication-on-ubuntu-16-04/|rosehosting.com]]
linux/ssh_gauth.1456010528.txt.gz · Dernière modification : 2020/07/24 22:03 (modification externe)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki