Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  49] [ 0]  / answers: 1 / hits: 6189  / 2 Years ago, thu, february 10, 2022, 11:02:07

I would like to strengthen the authentication of my SSH logins by adding another factor: a passcode generator device, or a passcode generation application on my mobile phone. The only obvious options in the default setup are a fixed password and key pair. How can I do this?



(If I use a password plus a passcode generator, this provides two-factor authentication (2FA): the password is “what I know”, and the passcode is “what I have”.)


More From » ssh

 Answers
0

One way to do this is with a tool provided by Google called Google Authenticator.




  1. Install libpam-google-authenticator Install libpam-google-authenticator




    • or just sudo apt-get install libpam-google-authenticator


  2. Edit /etc/pam.d/sshd to include the module:




    • sudoedit /etc/pam.d/sshd

    • and then include this line at the top of the file and save:



      auth required pam_google_authenticator.so


  3. Edit your SSH config file to turn on the challenge:




    • sudoedit /etc/ssh/sshd_config and then change the response authentication from:



      ChallengeResponseAuthentication no 


      to



      ChallengeResponseAuthentication yes


      and then save the file.



  4. sudo restart ssh to restart SSH


  5. Run google-authenticator




    • This will give you your secret key, verification code, and emergency scratch codes. It will also ask you some rate limiting questions.




Mobile Applications:



You'll need one of these to receive the authentication code on another device.





Related and Useful:





Note that combining a password with single-use passcodes is two-factor authentication: it combines “what you know” (a password) with “what you have” (the passcode generator device). On the other hand, if you combine single-use passcodes with an SSH key pair, it's all about “what you have”. When two authentication factors are of the same type, you do not have two-factor authentication; this is sometimes called “one-and-a-half-factor authentication”.


[#37084] Friday, February 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ilityushing

Total Points: 18
Total Questions: 100
Total Answers: 113

Location: Senegal
Member since Wed, May 13, 2020
4 Years ago
;