linux:ssh_gauth
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
linux:ssh_gauth [2016/03/22 19:02] – [Configurer PAM] gdureuil | linux: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 ====== | ||
- | <WRAP center | + | ===== Information ===== |
+ | |||
+ | <WRAP center info 100%> | ||
Testé sur Debian 8. | Testé sur Debian 8. | ||
</ | </ | ||
- | |||
===== Installation ===== | ===== Installation ===== | ||
- | Installer les packages | + | Installer les packages. |
- | + | ||
- | < | + | |
- | apt-get install build-essential make automake m4 autotools-dev libtool libpam0g-dev libpam0g unzip qrencode | + | |
- | </ | + | |
- | + | ||
- | (Ici unzip sert à décompresser l' | + | |
- | + | ||
- | Télécharger et décompresser les sources de libpam authenticator sur Github (voir lien " | + | |
- | + | ||
- | < | + | |
- | cd / | + | |
- | wget https:// | + | |
- | unzip googleauth.zip && rm googleauth.zip | + | |
- | cd google-authenticator-master/ | + | |
- | </ | + | |
- | + | ||
- | Penser à adapter l'URL pour la dernière version et donc le nom du dossier qui est extrait | + | |
- | + | ||
- | Lancer la compilation | + | |
- | <code> | + | <sxh bash;> |
- | ./ | + | apt install |
- | ./ | + | </sxh> |
- | make | + | |
- | make install | + | |
- | </code> | + | |
===== Configuration ===== | ===== Configuration ===== | ||
Ligne 44: | 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, | Cinq questions vont être posées, les réponses YES sont les plus sécurisées, | ||
- | <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 "/ | Do you want me to update your "/ | ||
| | ||
Yes | Yes | ||
- | </code> | + | </sxh> |
Le fichier sera généré pour l' | Le fichier sera généré pour l' | ||
- | <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, | 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, | ||
| | ||
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 90: | Ligne 69: | ||
Editer le fichier de configuration PAM | Editer le fichier de configuration PAM | ||
- | <code> | + | <sxh bash;> |
nano / | nano / | ||
- | </code> | + | </sxh> |
Ajouter à la fin | Ajouter à la fin | ||
- | <code> | + | <sxh text; Title: / |
- | auth required | + | auth required pam_google_authenticator.so nullok |
- | </code> | + | </sxh> |
Le paramètre nullok permet à un compte utilisateur, | Le paramètre nullok permet à un compte utilisateur, | ||
Ligne 106: | Ligne 85: | ||
Editer le fichier suivant | Editer le fichier suivant | ||
- | <code> | + | <sxh bash;> |
- | / | + | nano / |
- | </code> | + | </sxh> |
Chercher '' | Chercher '' | ||
Ligne 114: | Ligne 93: | ||
Redémarrer le service ssh | Redémarrer le service ssh | ||
- | <code> | + | <sxh bash;> |
/ | / | ||
- | </code> | + | </sxh> |
===== Tester la connexion ===== | ===== Tester la connexion ===== | ||
- | Vérifier la configuration dans < | + | Vérifier la configuration dans '' |
Tester la connexion en SSH. | Tester la connexion en SSH. | ||
- | Si problème, vérifier | + | Si problème, vérifier |
+ | |||
+ | ===== Restreindre à une liste d' | ||
+ | |||
+ | On peut restreindre l' | ||
+ | |||
+ | <sxh bash;> | ||
+ | nano / | ||
+ | </sxh> | ||
+ | |||
+ | Et ajouter : | ||
+ | <sxh text; Title: / | ||
+ | AllowUsers root mon_user_1 mon_user_2 | ||
+ | </ | ||
+ | |||
+ | ===== Sources ===== | ||
- | [[http://pirmax.fr/2014/02/13/securiser-les-connexions-ssh-avec-google-authenticator/|Source 1]] - [[http://www.linux.org/threads/ | + | [[https://github.com/google/google-authenticator|github.com/google/ |
linux/ssh_gauth.1458673372.txt.gz · Dernière modification : 2020/07/24 22:03 (modification externe)