Skip to content

Instantly share code, notes, and snippets.

@NicolaiSoeborg
Last active June 7, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicolaiSoeborg/e11b45fa408ec8abff52b7044bf12c65 to your computer and use it in GitHub Desktop.
Save NicolaiSoeborg/e11b45fa408ec8abff52b7044bf12c65 to your computer and use it in GitHub Desktop.
# Install fail2ban (ratelimit auth) and google auth (MFA)
sudo apt install fail2ban libpam-google-authenticator
# Setup MFA:
google-authenticator
# I'm using: y, y, n, n, y
Add `auth required pam_google_authenticator.so` to the end of `/etc/pam.d/sshd`
Also comment out `@include common-auth` after doing the steps below.
In `/etc/ssh/sshd_config`:
* set `ChallengeResponseAuthentication yes`
* add `AuthenticationMethods publickey,password publickey,keyboard-interactive`
## Stuff to keep in mind
If your home-folder is encrypted (i.e. per user encrypted folders, not full disk encryption), then you need the folder to be decrypted, before trying to read `~/.google_authenticator` Or you need to move the MFA secret.
If you are rolling out the MFA on a system with multiple users, you probably want to use `auth required pam_google_authenticator.so nullok` until everyone uses MFA.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment