Ssh – Google authenticator / SSH: multiple shared secrets per user & sharing of shared secrets over users

ssh

I would like to add Google's authenticator app to our SSH authentication toolchain, as described in this article

However, it seems that the PAM module basically makes a hard link between "linux user" and "authentication user". This causes the following 2 problems for us:

  • If we have multiple users on the system (for multiple different purposes), it is hard (impossible?) to share the google authentication method (TOTP shared secret) between them.
  • If multiple real people want to log in on the same linux user, this forces us to share the secret among the real users.

In the standard SSH approach, where any real person's key can be added to any given linux user's authorized_keys, these problems are not applicable. How do I create the equivalent in the Google-pam setup?

Best Answer

Shared accounts do not work well with 2-factor authentication, as 2fa generally exists to prove that a user is who they say they are. Instead of shared accounts you should be using roles or user switching: someone connects with their own credentials as their own account and then performs a sudo operation to become a shared account. This has multiple benefits, including much improved auditing capabilities.

I do not believe you can make PAM work the way you want it without creating a shared secret that you give to all your users -- and even then you will have trouble when people will be locked out due to token reuse (e.g. userA connects and uses token 555555, then userB connects at the same time and tries to use the same token 555555, which fails because it's already been used once). I believe you can allow token reuse in stock google authenticator, but that basically negates the whole "one-time" part of "OTP".