How to Set Up Two-Factor Authentication for Login and Sudo
linux.com
linux.com
https://en.wikipedia.org/wiki/Time-based_One-time_Password_A...
The only requirements of TOTP are an accurate time source and keying data for an HMAC. No internet connectivity explicitly required.
That being said, HOTP is theoretically more secure than TOTP because even if the secret is exposed (e.g. old backup) they'd still need to crack the counter. It also does avoid clock problems.
I almost think the ideal solution would be to set up TOTP primarily and HOTP as a backup. Two different accounts, and you take the HOTP secret (likely QR code), print it, hide it, and destroy the digital copy.
https://github.com/google/google-authenticator/blob/3fb90bda...
This older article shows a bit of the hoops one could jump through to get a complete system (including the scratch codes etc):
https://www.serverstack.com/blog/2013/02/21/implementing-tot...
I've successfully played with the python oath code to get 2fa working with "Star Wars: the Old Republic" (the game has a pretty broken interface for setting up 2fa - to the point that a lot of people give up, even if they give subscribers a 20% monthly bonus in in-game currency for using 2fa...).
https://github.com/bdauvergne/python-oath
Highly recommended for debugging/playing with OATH, in addition to the "main" oath tools, which IMNHO are much better documented (and comes with the binaries needed to do everything, like manually generating codes etc):
http://www.nongnu.org/oath-toolkit/pam_oath.html
For Debian: https://packages.debian.org/jessie/libpam-oath
See also the always excellent Arch Linux wiki, which adds a tip about generating qr-codes from the secret (so you can store the secret in eg: Google Authenticator easily):
No. HOTP and TOTP are treated separately. Both of which are separate from scratch codes.
HOTP can't "show the future" (well, you can generate multiple codes but it won't be useful for this) and have an order. Scratch codes are exactly N of them, and they're stored in ~/.google_authenticator and don't have an order. They're also twice as long because unlike the normal codes there's 8 (IIRC) valid ones, and they're ALL valid all the time. (until used)
https://github.com/google/google-authenticator/blob/3fb90bda...
And of course the switch statement that handles the core logic starts by checking scratch codes, and if that doesn't work, proceeds to check TOTP/HOTP:
https://github.com/google/google-authenticator/blob/3fb90bda...
I'm not a big fan of this style:
https://github.com/google/google-authenticator/blob/3fb90bda...
But at least there's a comment documenting the magic return code (#DEFINE VALID_SCRATCH_CODE = 0, or an enum, or basically anything else, anyone?):
/* Checks for possible use of scratch codes. Returns -1 on error, 0 on success, * and 1, if no scratch code had been entered, and subsequent tests should be * applied. */
[ed: Looks like it is independent: https://www.sudo.ws/man/sudoers.man.html
"sudoers uses per-user time stamp files for credential caching. Once a user has been authenticated, a record is written containing the uid that was used to authenticate, the terminal session ID, and a time stamp (using a monotonic clock if one is available). The user may then use sudo without a password for a short period of time (5 minutes unless overridden by the timeout option). By default, sudoers uses a separate record for each tty, which means that a user's login sessions are authenticated separately. The tty_tickets option can be disabled to force the use of a single time stamp for all of a user's sessions."
Note that the text uses "password", but I think it means "successfully authenticate". ]
Wouldn't a more elegant solution be to add Kerberos authentication combined with 2FA? You can then pay the price for access up front but someone phishing your password gets nothing since presumably they cannot answer the second factor challenge.
The advantage of U2F is that it uses an asymmetric scheme where a keypair is generated for each authentication endpoint, so the secrets never leave the hardware token in the first place. Compared to RSA SecurID, you would need to have a really severe threat scenario such that you can't even trust RSA with your keys. Of course, U2F is also a much more complicated protocol than say TOTP, and has not existed long enough to stand the cryptographic test of time.
To answer your second question, I'm not sure I understand what you mean. TOTP (Google Authenticator), RSA SecurID, and U2F are all different types of 2FA. They could all be combined with Kerberos if that is what you want.
Such as the one where RSA was compromised and secrets were leaked, sadly.
But there's a problem. If I had partial access and the first factor (password) I'd race the real admin's "sudo" for the U2F touch. Poll list of processes in a loop. If "sudo" was just started, ask for U2F before sudo has a chance. (e.g. by having a pre-started sudo paused in GDB).
U2F has its problems for non-web auth. Just look at how awkward the SSH patches are. (also not secure and/or anonymous (I forget), by the way. See mailing list threads)
1: https://www.vasco.com/images/DIGIPASS-for-Mobile-ES-201312-v...
Increasingly enterprises are allowing BYOD for this, with or without content protection systems like airwatch.
(The app supports QR)