Configure Two-Factor Authentication for SSH (Linux) in 8 Steps
Ready to Start Your Career?

Configure Two-Factor Authentication for SSH (Linux) in 8 Steps

solhuebner s profile image
By: solhuebner
March 7, 2016
liquid-stock-photo-cybraryLet's begin! 1 - Make sure the server time is correct. 2 - Configure NTP:

apt-get install ntp

service ntp reload

ntpq -p

 3 - Install the package that enables two-factor authentication. You can find the project here: -Configure two-factor authentication:

apt-get install libpam-google-authenticator

vi /etc/pam.d/sshd

Add the following line on top:

auth required

vi /etc/ssh/sshd_config

5 - Change ChallengeResponseAuthentication to Yes6 - Change to the user that should authenticate via 2FA

su userabc


7 - Answer only a few more questions and you're set. I'd recommend an app like the Google Authenticator or Authy if you use Android. You can use all applications that support the Time-based One-time Password Algorithm (TOTP).


service ssh restart

 8 - Test to login before closing shell! # Enjoy more security! #
Schedule Demo
Build your Cybersecurity or IT Career
Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry