How does 2FA relate to MFA and two-step verification?
2FA is the most common case of multi-factor authentication, with the count fixed at two. MFA is the general term and allows two or more. Two-step verification is a looser phrase: some services use it for a password plus a code sent by email, which is two steps but arguably not two independent factors if the same password unlocks the mailbox. The practical question is not the label but whether the second step would still protect you if your password leaked. Multi-Factor Authentication compares the factor types in depth.
What does a typical 2FA login look like?
- The user enters a username and password, which the server checks against a stored hash.
- The server sees that 2FA is enrolled and asks for the second factor.
- The user enters a six-digit code from an authenticator app, taps a security key, or approves a prompt.
- The server verifies the second factor and issues a session, often with an option to remember the device for a set time.
Remembering a device trades a little security for convenience. A sensible policy remembers trusted devices for a limited period and always asks again for actions such as changing the password or adding new keys.
How do I set up 2FA well as a user?
- Use an authenticator app or a security key rather than text messages where the service allows.
- Enroll two security keys if supported, and keep the spare somewhere safe.
- Save the recovery codes offline, for example printed in a drawer or in a password manager separate from the authenticator.
- Turn on 2FA first for the accounts that control others: email, domain registrar, DNS provider, code hosting and your identity provider.
- Back up authenticator secrets securely or use an app that supports encrypted export, so a lost phone does not mean losing every account.
How do I add 2FA to sudo on a server?
SSH logins are best protected with keys, and Multi-Factor Authentication covers SSH-specific setups. A different and often overlooked spot is privilege escalation: you can require a TOTP code for sudo, so a stolen SSH key alone cannot become root.
apt-get install -y oathtool libpam-oath head -c 20 /dev/urandom | od -An -tx1 | tr -d ' \n' > /root/ops.hex; echo echo "HOTP/T30/6 deploy - $(cat /root/ops.hex)" >> /etc/users.oath chmod 600 /etc/users.oath /root/ops.hex sed -i '1i auth requisite pam_oath.so usersfile=/etc/users.oath window=2 digits=6' /etc/pam.d/sudo oathtool --totp "$(cat /root/ops.hex)" # current code, for a quick test xxd -r -p /root/ops.hex | base32 # the form an authenticator app expects
Enroll the base32 value in the user's authenticator app, and keep a root shell open while testing. If xxd is missing, install it from the xxd or vim-common package depending on the release. Delete /root/ops.hex once the user has enrolled. The sudo command explains how sudo checks permissions after authentication passes.
How do people get locked out, and how do I avoid it?
Lost phones, factory resets and broken security keys cause most lockouts. On personal accounts, recovery codes and a second enrolled factor solve nearly all of them. On servers, the risk is configuration: a PAM change with a typo can block every login. Always test in a second session before closing the first, and keep a path that does not depend on the new setting, for example an emergency SSH key restricted to one source address. Our panel can reboot or reinstall a machine but does not give a console, so careful testing is the safe habit.
Is 2FA worth it for small teams?
Yes, and especially for them. Small teams often share a few powerful accounts, such as the registrar, the DNS provider and the main mailbox, and one leaked password there can redirect a domain or reset every other login. Turning on a second factor for those few accounts takes minutes and blocks the vast majority of automated takeover attempts, which rely on passwords from earlier leaks.
What should an app builder get right?
- Verify TOTP codes with a small time window and reject reused codes within the same window.
- Rate limit attempts per account and per address.
- Store TOTP secrets encrypted, since they are as sensitive as passwords.
- Show recovery codes once at enrollment and let users regenerate them.
- Log enrollments, removals and failed attempts, and notify users by email when 2FA settings change.
An app with these features runs well on a modest box such as the S2, which keeps response times low even when many users sign in at the start of a workday.
Machines for Apps With Secure Logins
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| E1 | Intel Xeon E3-1240 v3 | 4 / 8 | 16 GB DDR3 | 2x 240 GB SSD | 2x 1 Gbps | $30.52 | $91.56 (3 months) |
| S1 | Intel Xeon E-2276G | 6 / 12 | 64 GB DDR4 | 1x 1 TB NVMe | 2x 10 Gbps | $53.32 | $53.32 (1 month) |
| S2 | Intel Xeon E-2356G | 6 / 12 | 64 GB DDR4 | 1x 1 TB NVMe | 2x 10 Gbps | $58.39 | $58.39 (1 month) |
Keep Reading
Multi-Factor Authentication
Logins that need two or more independent proofs of identity, the factor types compared by strength, and adding MFA to SSH and web apps.
OpenAuthentication
How a system confirms that a user, device or service is who it claims to be, the main methods, and Linux logins.
OpenThe sudo command
How sudo decides who may run what, the flags you use daily, safe sudoers rules, logging and the habits that keep root powers contained.
OpenHarden SSH on Linux
A practical hardening list for sshd on a fresh dedicated box: keys, users, rate limits, firewall scope and an outside audit.
OpenFAQ
Quick Answers
A login that requires a password plus one more proof from a different category, usually a code or approval from a device you hold.
2FA is MFA with exactly two factors. MFA is the general term that allows two or more.
Use a saved recovery code or a second enrolled factor to sign in, then enroll your new device and remove the old one.
Yes. A PAM module such as pam_oath can ask for a TOTP code before sudo grants root access.
Email, domain registrar, DNS provider, code hosting and your identity provider, because they control access to everything else.