Mettre la double authentification sur SSH¶
Installer le paquet¶
On va installer le packet de Google Authenticator via la commande suivante :
sudo apt install -y libpam-google-authenticator
Configurer¶
Dans un premier temps, on va activer la double authentification par SSH en allant modifier le fichier suivant :
sudo nano /etc/pam.d/sshd
Puis ajouter la ligne suivante :
auth required pam_google_authenticator.so
Mais il faut également commenter une ligne :
# @include common-auth
Puis redémarrer le service via la commande :
sudo service ssh restart
Maintenant, il faut modifier la configuration SSH :
sudo nano /etc/ssh/sshd_config
Premièrement, ajouter une ligne dans le fichier :
AuthenticationMethods publickey,keyboard-interactive
Et il faut modifier les lignes :
KbdInteractiveAuthentication yes # SET TO YES
ChallengeResponseAuthentication yes # SET TO YES
Activer sur un compte¶
Pour cela, il faut éxecuter la commande de Google :
google-authenticator
Il va vous demandé si vous voulez un token basé sur le temps
Do you want authentication tokens to be time-based (y/n) y
Vous allez avoir un QRCode a scanné avec votre natel et rentrez le code.
Il va vous donnez des codes d'urgences, sauvegardez-les quelques parts de sécurisé et sur une autre plateforme.
Ensuite, il va vous posez quelques questions, il va falloir les configurer :
Do you want me to update your "/home/<user>/.google_authenticator" file? (y/n) y
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) y
By default, a new token is generated every 30 seconds by the mobile app.
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. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) 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) y
Vous avez terminé la configuration de votre appareil.