Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

SSH login does not work after enabling 2-factor. Getting failed to read ".google_authenticator"

Writer Matthew Martinez

I have a server running Ubuntu 20.04 and I wanted to try to set up 2 factor authentication to secure SSH logins.

I logged in to my server, and followed this tutorial: (EDIT: I deliberately removed the hyperlink because I don't recommend the tutorial. use Ubuntu's official tutorial instead)

The thing I did differently is that I used my own user (not root), which has sudo privileges. So instead of doing apt-get install libpam-google-authenticator -y, I did sudo apt-get install libpam-google-authenticator -y, etc.

I tried to sign out, and then I try to sign in again but it doesn't work. It asks me for a password over and over

~$ ssh birger@10.0.0.10
Password: <- I enter the password and hit ENTER
Password: <- I enter the password and hit ENTER
Password: <- I enter the password and hit ENTER
birger@10.0.0.10's password: <- I enter the password and hit ENTER
Permission denied, please try again.
birger@10.0.0.10's password: <- I enter the password and hit ENTER
Received disconnect from 10.0.0.10 port 22:2: Too many authentication failures
Disconnected from 10.0.0.10 port 22

I tried looking at the log file /var/log/auth.log and I notice these lines which I thought were relevant:

sshd(pam_google_authenticator) [9164]:Failed to read "/home/birger/.google_authenticator" for "birger"
sshd[9162]: error: PAM: Authentication faile for birger from 10.0.0.254

So my question is why does the SSH login fail, after I enabled Google 2-factor? What can I do to fix this? I tried looking for the file /home/birger/.google_authenticator that was mentioned in the log but it does not exist...

Luckily I have physical access to the server, so I can connect a monitor and keyboard to it and then I can log in with standard, local login.

5 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy