Finally a solution (thanks for supporting Google Cloud).
A few updates at the top of the document I talked about:
In addition to adding a line to /etc/pam.d/sshd , you should also comment on the @include common-auth line. Therefore, it should be something like:
auth required pam_google_authenticator.so
In addition to changing the ChallengeResponseAuthentication property in / etc / ssh / sshd_config , you must also add AuthenticationMethods publickey, which is keyboard-interactive in the following line:
ChallengeResponseAuthentication yes
Of course, this applies to the usual instructions for installing libpam-google-authenticator, changing sshd and sshd_config (as mentioned above), restarting the ssh / sshd service, and setting up google authenticator for the account.
Finally, a few more points:
- Observe this carefully - after restarting the ssh / sshd account, no one can log in without the proper 2FA. Therefore, make sure that anyone who needs access to ssh has configured it correctly.
- I am considering whether this is a suitable solution for us, since it requires the installation of virtual machines (each individual virtual machine) and manual authentication settings for each account and each virtual machine manually. Not sure how scalable this alternative is. I would be grateful for your thoughts ...
- Last, but not least, the installation of the libpam-google authenticator can be simplified with apt-get, without having to manually install all the dependencies and create it. Worked for me by running:
sudo apt-get install libpam-google-authenticator
Good luck
source share