2FA for RHEL 8 for sudo commands and local login (not ssh)

Latest response

Hello friends, i have been trying to add 2FA with google authenticator for 2 days and i am getting nervous.. Since i am not a pro user of redhat i found some solutions on the internet but all of them were for ssh and quite a few were also for sudo commands and local login without ssh.

The problem is that they seem not to work.

This is the solution i was trying:
Edit the /etc/pam.d/system-auth file and add the following line at the top:
auth required pam_google_authenticator.so
Edit the /etc/pam.d/login file and add the following line at the top:
auth required pam_google_authenticator.so

After this on login i get 2 times verification code which does not work.. How to make this work for sudo commands and login and be with the following order: password than verification code because with this implementation the order is verification code than password..

Thank you friends,

Greetings

Responses