In response to the users that flagged this as a potential duplicate, it is not. I have a SSH hardening solution, which I got off Canonical's ubuntu tutorials and is commonly repeated, but it isn't working, as I outlined below.

On my Ubuntu 18.04 box I've attempted to setup two-factor authentication for SSH per this tutorial, however when I attempt to login via SSH it fails. I'm prompted for my username as normal, then my password. No matter what it returns "Access denied" when I've entered my password. If I comment out

auth required pam_google_authenticator.so

from /etc/pam.d/sshd then SSH works again, but obviously without two-factor. What is stopping my password from being accepted?


Never mind, I got it to work. The .google_authenticator file was not created properly in my home directory (not sure why though, possibly I ran google-authenticator under the wrong user, possibly as root?), so after re-running it everything works fine.

  • You may accept your own answer to get this marked as Solved. – ubfan1 Feb 28 '19 at 2:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.