-
-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DietPi-Config | Add support for 2FA SSH with Google Authenticator PAM module (TOTP/HOTP) #5592
Comments
I am a total noob in scripting this or I would have made a proposal for it. |
probably better to add this to our online docs to describe how to activate 2FA and how to use SSH key authentication. |
Since there are a lot of such 2FA authentication methods, which can be invoked into PAM, it is hard to cover this as an option within our scripts. Some hints in our docs sound more reasonable to me as well. Moreover, key authentication is pretty simple and very strong in terms of security, unless you keep your private key unsafe, of course, which can be encrypted with another passphrase if not stored on a sufficiently secured client. Another benefit is to not rely on 3rd party services, especially not from data collector companies like Google, being a major privacy benefit. What are your particular concerns/issues with key authentication @GvY85? |
Thanks for the replies. The fact that the PAM module is called "Google Authenticator" is because it is a piece of open software developed by Google that implements TOTP/HOTP. You can use any authenticator app on your mobile phone or pc with it that supports these protocols (Authy, Microsoft Authenticator, Yubico Authenticator, etc) and it has nothing to do with Google at all. other than Google engineers working on it |
Okay, thanks for the info. I think it is about personal workflows whether key authentication is feasible or not. I personally connect only with a single machine to my SSH servers and would put the key onto another, phone or whatever, if required. But if one works with many clients, or on not trustworthy client systems, remotely etc, 2FA may be a better choice. If the Google authenticator module is the only one, we may add it. In theory it works for other system logins as well, since it's PAM. Dropbear has very limited PAM support, but who knows. |
Exactly, think we are in sync on this. |
Hi @GvY85 Also, for context, Do you think I could be missing something? |
@MichaIng I too would like to request for this feature. |
Found the reason why it didn't work in debian bookworm Also, refer below guide in case you are using @MichaIng would really appreciate if this too can be added as part of setup process somewhere. 2FA definitely improves security for SSH. I hope you consider it. |
I missed your earlier comments. I migrated from Bullseye with the 'old' settings and those work as well.
|
However, still makes sense to update this setting: |
For some reason I never liked/understood logging in with public SSH keys and the distribution of those among client devices.
So I have always been logging in with a (root) password on my 2 DietPi servers but that never felt safe enough.
Recently I found out you can use a password + 2FA (TOTP) via the Google Authenticator package and thus use your phone with any app that supports TOTP (Yubikey, Google Authenticator, Authy, etc).
You can also use public key authentication + 2FA but I have not tried that out.
Steps for using a password + 2FA with DietPi:
1:
dietpi_software
-> choose OpenSSH as SSH Server2:
sudo apt install libpam-google-authenticator
3: add
auth required pam_google_authenticator.so
to/etc/pam.d/sshd
4:
sudo systemctl restart sshd.service
5: edit
/etc/ssh/sshd_config
and change/addChallengeResponseAuthentication yes
and (optinally) add a#
in front ofSubsystem sftp /usr/lib/openssh/sftp-server
to disable SFTP if you where using Dropbear before and did not have SFTP.6: run
google-authenticator
and answer these questions:To the question if you want to use time-base authentication: y
7: Scan the QR code and back up the code/recovery code.
Do you want me to update your "/home/exampleuser/.google_authenticator" file (y/n)
-> y-> y
-> n
-> y
8: reboot and you should be good to go.
The text was updated successfully, but these errors were encountered: