Free tools Windows power users keep installed
One-click scans. No signup required.
On Ubuntu Server, a practical way to require two factors for SSH is to authenticate first with an SSH key and then with a time-based one-time password (TOTP) through PAM. Before enforcing it, enroll every SSH user, confirm key-only access, and verify that you can recover the server through your VPS provider’s console. The procedure below protects SSH logins; it does not automatically protect provider accounts, web apps, databases, or every user account on the VPS.
What SSH two-factor authentication protects
With the PAM-backed Ubuntu configuration, SSH requires a public-key authentication step followed by a keyboard-interactive prompt for an OTP. The private key stays with the client; the OTP comes from an authenticator using a secret configured for that user. Ubuntu’s documented configuration disables SSH password authentication while requiring both methods.
This is separate from MFA on your VPS provider account. Provider-console access is another administrative route, and its MFA and recovery controls must be checked separately. The instructions here concern SSH; sudo requires its own deliberate configuration if you also want a second factor for privilege elevation.
This guide centers on Ubuntu Server’s current TOTP/HOTP instructions, last updated June 26, 2026. PAM layout, package names, OpenSSH versions, and configuration directives can differ on other distributions. Do not copy Ubuntu PAM changes to a different system without following that distribution’s current documentation.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Prepare access and recovery before changing SSH
- Identify the distribution and release:
cat /etc/os-release. Ubuntu 20.04 LTS and earlier use a legacy SSH directive noted below. - Confirm you can log in over SSH now, have a separate sudo-capable administrator account, and can access your VPS provider’s out-of-band console or rescue route. Recovery procedures vary by provider; verify the route before relying on it.
- Keep an existing privileged SSH session open while making changes. Use a second terminal for all new-login tests, and do not close the first session until the full key-plus-code flow succeeds.
- Set up and test SSH public-key access for every person or automation account that needs SSH access. Do not assume password login is a safe fallback once MFA is enforced.
- Enroll each intended SSH user with an OTP secret before requiring the second factor. A user without a configured key and OTP secret may be unable to complete SSH setup after enforcement.
- Keep recovery material somewhere protected and separate from the VPS where practical. A copy of the OTP secret or emergency codes can let someone bypass the intended protection if exposed.
Vultr’s April 1, 2025 guide also lists updating the system, configuring a firewall, and using SSH keys among its prerequisites. Its specific console and configuration guidance applies to Vultr; check your own provider’s recovery process.
Choose TOTP/HOTP or a hardware security key
| Method | Credential and requirements | Important failure mode | Recovery consideration |
|---|---|---|---|
| PAM TOTP/HOTP | A per-user shared secret generates a code. The SSH path uses PAM and keyboard-interactive prompts. | TOTP depends on aligned clocks. HOTP can desynchronize if codes are generated without the server advancing in step. | Securely protect emergency codes, authenticator backups, or alternate administration access; exposure can defeat the extra factor. |
| OpenSSH U2F/FIDO security key | Uses an OpenSSH security-key credential, such as ecdsa-sk or ed25519-sk, with compatible client, server, and hardware. |
The hardware device must be present and available to authenticate. | Plan a suitable backup device or alternate access route for your deployment; requirements depend on the hardware and SSH setup. |
Ubuntu recommends U2F/FIDO hardware authentication devices for the best two-factor security where practical. TOTP is a practical alternative when a hardware route is not suitable. Ubuntu’s TOTP guide says its presented U2F/FIDO and TOTP/HOTP configurations are not recommended together because that combination has not been tested there; choose a documented path rather than mixing them casually.
Configure PAM-backed OTP on Ubuntu
Install the PAM module
- On Ubuntu, update package metadata and install the documented module:
sudo apt update && sudo apt install libpam-google-authenticator. - As each SSH user, run
google-authenticatorand follow the prompts for that installed version. Import the displayed QR code into a compatible authenticator app, or enter the secret manually. Keep the secret and any generated emergency passcodes confidential. - Repeat enrollment for every user who needs SSH access. Keep your working privileged session open while you configure and test.
The user’s authenticator configuration file contains the shared secret, emergency passcodes, and settings, so protect it like a credential. Use the current module prompts and version-specific guidance rather than assuming an older tutorial’s defaults or prompts still apply. Ubuntu’s older tutorial describes rate limiting and preventing multiple uses of a token as options; treat those as version-specific setup choices, not timeless defaults.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Configure the SSH daemon and PAM
Follow the current Ubuntu Server TOTP/HOTP procedure for the relevant Ubuntu release. Its SSH configuration excerpt is:
KbdInteractiveAuthentication yes
PasswordAuthentication no
AuthenticationMethods publickey,keyboard-interactive
Ubuntu 20.04 LTS and earlier use ChallengeResponseAuthentication yes instead of KbdInteractiveAuthentication yes in this configuration. Check the active SSH configuration and included files for existing or conflicting directives; adding duplicate lines without understanding which value takes effect can leave authentication in an unintended state.
Ensure /etc/pam.d/sshd invokes the OTP module in the way specified by Ubuntu’s current instructions. An older Ubuntu tutorial gives the PAM line auth required pam_google_authenticator.so, but its examples use legacy configuration names; prefer the current Ubuntu Server procedure over that older variant.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Audit the PAM path before enforcing it
KeyboardInteractiveAuthentication is a way to present interactive prompts; it is not inherently an OTP-only channel. PAM can also offer password authentication through that path. Mozilla’s OpenSSH guidance warns that PasswordAuthentication no alone does not prove SSH password authentication is impossible if PAM still enables it.
- Inspect
/etc/pam.d/sshdand the PAM files it includes. Understand which authentication modules can answer the keyboard-interactive prompt. - Verify that the effective SSH settings require
publickey,keyboard-interactive, and that the PAM path implements the intended OTP step without an unintended password fallback. - Test with a fresh client session and confirm that a valid key alone does not complete login and that the expected OTP prompt appears. Do not infer security from a configuration line in isolation.
PAM stacks differ across distributions and releases, so there is no safe universal replacement file for every Linux VPS. Use the vendor’s current instructions for non-Ubuntu systems and understand their PAM includes before changing authentication.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Reload and test without losing your session
- Review the SSH and PAM edits against the instructions for your exact release. Resolve conflicting directives rather than leaving multiple competing values.
- Validate the SSH daemon configuration using the command and reload or restart procedure documented for that release. A syntax check can catch some errors, but it does not prove that the authentication flow works.
- From a second terminal, start a new SSH connection. Confirm that the intended key is accepted and that SSH then requests the OTP. Complete login successfully before ending the existing session.
- If the test fails, use the still-open session to correct the configuration. If you have lost SSH access, use the provider’s verified console or rescue route; do not assume the recovery path is identical across providers.
OTP timing, backups, and lockout recovery
TOTP clock mismatch
TOTP derives the expected code from time, so the authenticator and server clocks must be sufficiently aligned. If valid-looking codes are rejected, check time synchronization on both devices before changing PAM settings. Ubuntu generally prefers TOTP when the authenticator supports it.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
HOTP desynchronization
HOTP advances through a sequence as codes are requested. If the authenticator generates codes but the server does not advance in step, the two can get out of sync. Use your planned out-of-band administration route to recover rather than repeatedly generating codes and making the mismatch worse.
Lost or unavailable authenticator
Ubuntu lists authenticator backup or sync, written backup codes, multiple enrolled TOTP devices, and another authentication path to rerun setup as possible mitigations. These backups also weaken the extra factor if an attacker gets them. Protect them accordingly; avoid keeping a raw shared secret in an unencrypted notes-sync service.
Vultr’s April 1, 2025 guide gives an example of generating 10 emergency codes and using a 30-second TOTP period. Those are values in that guide’s example, not universal defaults. Follow the prompts and documentation for your actual module and release.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Troubleshoot common SSH MFA failures
| Symptom | Likely cause | What to check |
|---|---|---|
| SSH accepts the key but never prompts for a code | Keyboard-interactive is disabled, the required authentication methods are not effective, or PAM does not invoke the OTP module. | Check the effective SSH configuration, release-specific directive, and /etc/pam.d/sshd path and includes. |
| A password prompt appears instead of an OTP prompt | The PAM keyboard-interactive path may still allow password authentication. | Inspect the PAM stack and its includes; PasswordAuthentication no alone may not disable password authentication through PAM. |
| The OTP is rejected | The server and authenticator clocks may be misaligned, or the user may be entering a code for a different secret. | Check clock synchronization and verify that the enrolled secret belongs to the SSH account being tested. |
| HOTP codes stop working after generating several | The client and server counters may have become desynchronized. | Use the prepared recovery route to resynchronize or reconfigure securely. |
| A user cannot log in after enforcement | The user may not have enrolled an OTP secret, configured a key, or used the expected authentication path. | Use the existing admin session or provider console to restore access, then enroll and test that user before re-enforcing requirements. |
| SSH fails to reload after edits | A syntax error or conflicting setting may be present. | Keep the original session open, validate configuration using release-appropriate tools, and correct the error before trying another login. |
Keep the rest of the VPS secure
SSH MFA is one control, not a complete VPS security plan. Keep the operating system and exposed services maintained, restrict network access with a firewall appropriate to your services, protect provider-account access, and review which users and keys retain administrative access. MFA on SSH does not automatically extend to applications or databases running on the server.
Or let it run in the cloud
If the VPS is for a continuous YouTube channel rather than server administration, StreamNeo is a separate cloud service for looping uploaded videos as a YouTube live stream. Upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay running on your home computer; uploads stream as made, up to 4K 60fps, at one flat price per slot; StreamNeo automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly: $9.99 per month. See StreamNeo, or start the free first day.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




