TOTP Codes in the Terminal
jpmens.net
jpmens.net
> pass edit git/hub
[... put in your totp ...]
otpauth://totp/GitHub/...
then you can > pass otp -c git/hub
Copied OTP code for git/hub to clipboard. Will clear in 45 seconds.
pass-otp is also compatible with the passff firefox plugin; not sure beyond that.https://git.zx2c4.com/password-store/tree/src/password-store...
This is the same concept behind the fact that it typically makes little to no sense to hash phone numbers or credit card numbers.
(* The clipboard exposure was more limited...although probably only in a "security by obscurity" sense :P)
GNU Pass is a great example of Unix-y interoperability for me. I sync the .password-store folder over to my phone with Syncthing, where the Password Store android app reads it. Password Store in turn talks to OpenKeychain for my encryption key with biometrics support. Changes are also synced back to my other devices. Each piece of the puzzle can focus on doing one thing and doing it well, even on Android!
Password store for android: https://f-droid.org/packages/dev.msfjarvis.aps/ Openkeychain: https://f-droid.org/packages/org.sufficientlysecure.keychain...
With syncthing it's just instantly everywhere whenever I add an account, no action required. That's particularly useful when I create an account on my computer, then have to scan an OTP QR code with my phone. By the time my phone's out of my pocket the fresh account is already in the store to save the OTP code into.
A couple of iOS notes:
- The iOS app has a nasty bug, when you have not the latest repo on your iPhone, it cannot merge changes. So I recommend syncing your repo first, and then add new passwords from your mobile. IIRC, Android has no issues with that, but I’m not sure here.
- If you have a complicated ssh key (I have gpg-key for that) the iOS client doesn’t work properly. Could also have issues with other keys. IIRC, it’s the iOS issue. So I use a very special iPhone-only key that I added to my GitLab repo, where my passwords are stored. I generated the key with `ssh-keygen -t rsa -b 4096 -m PEM -f /tmp/id_rsa` and transferred it to my iPhone via iTunes, to ‘pass for iOS’ application.
----
[1]: GitHub: https://github.com/android-password-store/Android-Password-S... + Website: https://passwordstore.app/ + Play Store: https://play.google.com/store/apps/details?id=dev.msfjarvis.... + F-Droid https://f-droid.org/packages/dev.msfjarvis.aps/
[2]: GitHub: https://github.com/mssun/passforios + AppStore: https://apps.apple.com/us/app/pass-password-store/id12058205...
Syncthing may just work here, but for me, I don’t run Syncthing all the time, only when I need to sync some changes, which is infrequent for me. As well as my passwords, actually. I don’t care too much with my mobile, as I try to limit my smartphone usage and pick laptop whenever possible, so to avoid over-consumption of media (which is easier on a modern smartphone). But that’s just another story.
I'm no fan of bash or pass's rather anemic built in structure but I don't feel like gopass were the right stewards.
I suspect most people make the assumption that an Authenticator app is something special that needs to talk to the service that issued the QR code/secret string.
It's nothing more than a SHA1 hash of a secret string and an adjusted current time.
[1] <https://keepassxc.org>
On my computer, I also use a distinct password to protect my pass-otp secrets.
Autofill can save you a lot of time if you prefer to usually stay logged out of websites (auto-deleting cookies, for example) but need to log in sometimes.
keepassxc-cli show -q "$KEEPASS_DB_FILE" "$ENTRY_NAME" --totp
<type password>
<prints totp>
edit: doubly so specifically regarding Authy since theyre discontinuing it on the desktop in a few months.I strongly prefer other factors (U2F/FIDO(2)/WebAuthn/Passkeys/whatever) but unfortunately TOTP is still extremely prevalent. Worse is when only a single secondary factor can be registered, in which case even if something other than SMS or TOTP is available, I slightly bias away from hardware security tokens in order to have a clear recovery path. I can at least back up most TOTP keys.
I agree that having a second vault for TOTP seems superior but from a UX and recovery perspective it's not so clear. Are both vaults available on all devices? Are they usually unlocked simultaneously? Is it likely that one vault but not the other would be stolen? Or you have a separate device or air-gap and now the usability adds friction. It seems like diminishing returns.
Conversely a single vault still offers significant protection from many attack vectors, including keyloggers and phishing. Even if access is obtained via MITM'ing a TOTP, the blast radius is often limited to a single session. Many services have poor session security, once established, but many do not. And in my experience it's still nearly impossible to get rid of SMS 2FA.
TOTP is almost always strictly better than SMS 2FA, and storing your TOTP keys alongside your passwords doesn't really diminish the effectiveness of TOTP very much at all. Unless you have the keys themselves exposed, they're still closer to "something you have" than "something you know", at least from where I'm sitting.
Their main weakness is that they can be backed up or copied at all, as well as MITM'd. How I securely store them doesn't have much impact.
Most of the other threats that people talk about TOTP fixing are movie plot threats and not ones that happen in the real world to ordinary people. The only major exception is that webauthn prevents phishing, but TOTP cannot help with that.
You might fool me with that phishing page, but you won't fool my password manager's autofill. It would have to be full on MITM or DNS poisoning for that to work, which is already more of a movie plot.
Which is also a major strength. I've had the experience of a phone app losing all of my TOTP information, and spending a long while having to use the recovery paths of various websites. After that experience, I want my second factor to be something I can back up and restore.
That'll continue to be true until either all websites reliably accept multiple 2FA devices (e.g. register multiple hardware keys) or I can buy multiple redundant hardware devices that produce the same TOTP codes so I can register "one" device with a site and still have a backup.
I wish the Firefox password manager had builtin TOTP support.
2. using password managers for TOTP is useful
Both can be true simultaneously.
The point of "something you have" is that it is "literally infeasible" to compromise your account without physically robbing you of your yubikey-equivalent. That automatically excludes >99% of the population that aren't within X miles of you from being able to potentially attack you.
Using this definition, both SMS and TOTP already fail, but at least one can approximate it by storing the TOTP on a physical device in a way that blocks casual export.
If you store it in a (non-local/backed up) password manager, you completely give up the pretense that "it is impossible to compromise your account without physically robbing you of your yubikey-equivalent". Someone from across the world can now compromise you without leaving their room.
Now again, just because it doesn't meet the "2FA threshold", doesn't make it useless. But it is also true that it doesn't provide the level of security that 2FA is supposed to provide.
oathtool - Open AuTHentication (OATH) one-time password tool
OATH Toolkit provide components to build one-time password
authentication systems. It contains shared C libraries, command line
tools and a PAM module. Supported technologies include the
event-based HOTP algorithm (RFC 4226), the time-based TOTP algorithm
(RFC 6238), and Portable Symmetric Key Container (PSKC, RFC 6030) to
manage secret key data. OATH stands for Open AuTHentication, which is
the organization that specify the algorithms.It seems like this method at least keeps the secret key inside 2FAS backups, so it's probably slightly better opsec.
There are a few gists floating around regarding how to export by remote chrome debugging an older version of Authy desktop app, which still worked for me recently. This page explains too:
you just need to generate their html and on it, you will see a bunch of QR codes -- just use them to add a new TOTP to whatever tool you use.
I was also pissed off by the clock issue, so I'd show both the previous, present and next code to come: because it's really a PITA when you see 213987 but you've got only two seconds left before it rolls. So I may as well start entering the next code (what the server accept is something not in my control).
And I always, always, always have a known, public, 2FA which I can use to double-check that everything is smooth (for example by entering it on some online computer and verifying that I get the same tokens generated).
I just reused whatever 2FA/TOTP Java library I found and wrapped that in a little CLI utility.
My secrets were unlocked by entering a password when I'd start the app.
Your setup on raspberry Pi sounds complicated. Mine was simpler. Just a CLI showing totp. Less secure but more convenient.
op item get <item_name> --otp
To copy to clipboard just use pbcopy or xclip: op item get <item_name> --otp | pbcopy # MacOS
op item get <item_name> --otp | xclip -sel c # Linuxhttps://developer.1password.com/docs/cli/secret-references/#...
https://shop.reiner-sct.com/authenticator/reiner-sct-authent...
Surprisingly usable for a few day's worth of hacking around!
rbw is written in Rust and doesn't need premium for TOTP.
As for the cost, it's both reasonable at the yearly rate and I want to support them so they can continue improving the software (still waiting for Passkeys on mobile for example).
I can't really speak to the node part, but it seems to perform well enough in my experience.
To be honest, password managers that support TOTPs should always come with a very clear disclaimier that keeping all your eggs in the same basket is a detriment to your safety, and that you should either use a different software for these codes or a separate account. I don't believe they do, but correct me if I'm wrong.
- It's still something you have, and don't know: the TOTP secret. What you transmit is a short term generated code, but unlike your password, you don't send the secret key at any point.
- The downside of air gapped tokens is that when they break or are lost or stolen, you have to somehow re-enroll with a new device. The security properties of this process are deeply variable between authorities, and there's always the risk of just total loss of access. If you have the TOTP secrets backed up in Bitwarden, you can avoid this.
- Vault software can keep all of these secrets encrypted using keys protected by biometrics on a phone, or an external device like a Yubikey, that are only unwrapped by a particular physical interaction. Usually the vault software does a better job than the average person of determining whether you're looking at a legitimate authentication prompt or a phishing site, and I suspect it's less likely to automatically enter your TOTP code into the wrong than a person is when transcribing it by hand or copy pasting.
$ ykman oath accounts code <slot>
Touch your YubiKey... totp() {
TOKEN=$(keyring get totp $1)
oathtool -b --totp $TOKEN | xclip
}
and my TOTP secrets are saved via ansible-vault - name: set TOTP in keyring
with_items: "{{ TOTP }}"
community.general.keyring:
service: totp
username: "{{ item }}"
password: "{{ TOTP[item] }}"
keyring_password: "{{ keyring_password }}"I would instead recommend something like:
totp() {
oathtool --base32 --totp -- @<(keyring get totp "$1") | xclip
}
(Bash required.)For extra benefit, bind a keyboard shortcut and use xsel (Linux) or pbcopy (Mac) to drop the TOTP code into the clipboard. Now entering a frequent TOTP code is as simple as two keyboard chords.
(I only do this because my employer offers very limited options for MFA and I don't have a smartphone. I'd much rather use the Yubikeys I already have...)
It is a crude hack, but it works for me.
If it wasn’t I was going to bring it up, faith in lip synced music telly reconfirmed.