Two step verification for SSH using Google authentication in 3 simple steps
Google Authenticator (GA)
Google authenticator is a tool which generate 6 digits Time-based One Time Password(TOTP) for authentication which supports authenticator service(GA, Authy, ..).
Step 1 : Install Google authenticator
$ sudo apt update
$ sudo apt install libpam-google-authenticator
Step 2 : Configure Google authenticator
$ google-authenticator
time based authentication - y
Scan code using google authenticator ios or android app or type in the secret key
** Copy the emergency scratch codes
- Next type ( y )
- Type ( y ) to prevent man-in-the-middle attack
- Type ( n )
- Type ( y ) for rate limiting
** If detailed explanation is required please comment. I will make another post with detailed explanation.
Step 3 : Configure ssh
$ sudo nano /etc/pam.d/sshd
Add the following line to last line of the file
- auth required pam_google_authenticator.so
$ sudo nano /etc/ssh/sshd_config
Find and Replace
- ChallengeResponeAuthentication no
with
- ChallengeResponeAuthentication yes
$ sudo systemctl restart sshd
That it!
Try logging in
verification code is send to the mobile app
Comments
Post a Comment