SSH login does not work after enabling 2-factor. Getting failed to read ".google_authenticator"
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 22I 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.254So 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