Lewati ke konten utama

Security Tutorials

Two Factor Authentication Options Compared on KaliLinux.net

Compare TOTP and FIDO2 two-factor authentication on Kali Linux: pam_google_authenticator, oathtool, YubiKey SSH setup, and which fits your lab.

Two Factor Authentication Options Compared on KaliLinux.net

Two-factor authentication on Kali Linux splits into two practical paths: TOTP tokens you carry in a terminal, and hardware keys that plug into a USB port. KaliLinux.net readers keep asking which one is worth the setup time. The answer depends on your threat model, not brand loyalty.

TOTP: pam_google_authenticator and oathtool

Time-based one-time passwords run fine on Kali. The libpam-google-authenticator package wires TOTP into PAM, so SSH logins and sudo prompts demand a six-digit code after the password. Install it, run google-authenticator, scan the QR into any authenticator app, then configure /etc/pam.d/sshd.

For lab work, oathtool generates codes from a secret without a phone. Example: oathtool --totp -b BASE32SECRET prints the current token. Handy in CTF labs where you script logins against a box you own.

The limits are real. TOTP secrets live on disk, and if an attacker already has root on your Kali host, that secret is readable. Phishing proxies have harvested TOTP codes since 2019, when the Modlishka tool demonstrated real-time relay. TOTP raises the bar. It does not close the door.

Hardware keys: FIDO2 and U2F on Kali

YubiKey and similar FIDO2 keys work on Kali for SSH via ssh-keygen -t ed25519-sk (OpenSSH 8.2+, released February 2020, added this). Plug in the key, touch it, and the private key never leaves the device. Phishing fails because the key verifies the origin.

Setup on a clean Kali install:

  1. sudo apt install libpam-u2f
  2. pamu2fcfg -u $USER > ~/.config/u2f_keys
  3. Add pam_u2f.so to /etc/pam.d/sudo and /etc/pam.d/sshd
  4. Enroll a backup key before locking yourself out

Caveat: a YubiKey costs money, TOTP is free. For a student lab, TOTP is the sane start. For an SSH bastion you actually expose, hardware wins.

Choosing between them

Compare on three axes: phishing resistance, recovery cost, portability.

  • TOTP: no phishing resistance, cheap recovery, runs anywhere
  • FIDO2: phishing resistant, recovery needs a second key, needs a physical port
  • Push notifications: phishing prone, moderate recovery, needs a phone

Kali’s strength is that both stacks coexist. You can enforce TOTP on sudo and FIDO2 on SSH at the same time. Sebntar, test it in a VM before touching your daily driver. Snapshot first; a broken PAM config locks you out of sudo with no obvious escape.

One more fact worth holding: NIST SP 800-63B (2017 revision, updated 2024 draft) treats phishing-resistant authenticators as the highest assurance class. That is the standards body saying hardware keys beat codes. If your Kali box guards anything real, follow that guidance.

Close

Start with TOTP on sudo, add a hardware key to SSH once the workflow feels normal. Test in a VM, keep a backup key enrolled, and read the PAM config twice. KaliLinux.net covers the tooling; the discipline is yours.

For the official OpenSSH FIDO documentation, see https://www.openssh.com/txt/release-8.2 .

Pertanyaan yang sering diajukan

Can Kali Linux use a YubiKey for SSH login?
Yes. OpenSSH 8.2 and later support ed25519-sk keys, so ssh-keygen -t ed25519-sk stores the private key on the YubiKey. Kali ships a recent OpenSSH by default.
Is TOTP or FIDO2 better for a Kali lab?
TOTP is free and fast to set up, which suits a lab. FIDO2 resists phishing and is better for any SSH service exposed beyond the lab. KaliLinux.net suggests starting with TOTP and adding a hardware key later.
How do I avoid locking myself out of sudo on Kali?
Snapshot the VM, keep an SSH session open, and enroll a backup key before editing /etc/pam.d/sudo. A malformed PAM line blocks sudo with no recovery prompt.
Does two-factor authentication stop credential theft?
It limits damage. Stolen passwords alone fail, but TOTP codes can be relayed by phishing proxies. Hardware keys close that gap because they verify the origin.