Remote Desktop 2FA: Setting up TOTP on TeamViewer, AnyDesk, RDP, GoDesk

You're worried about someone getting into your remote sessions with just a stolen password — and rightly so. Remote desktop credentials are prime targets: phishing, credential stuffing, and leaked passwords can all give an attacker full int…
You're worried about someone getting into your remote sessions with just a stolen password — and rightly so. Remote desktop credentials are prime targets: phishing, credential stuffing, and leaked passwords can all give an attacker full interactive access. This guide walks through how to add a second factor — specifically TOTP (time‑based one‑time passwords) — to the major remote access flows: TeamViewer, AnyDesk, Microsoft RDP (on‑prem/RD Gateway), and notes for self‑hosted setups like GoDesk.
Why remote desktop 2FA (TOTP) matters
Passwords alone fail often. Brute force, reused credentials, and social engineering are common attack vectors. Adding 2FA reduces the attack surface by requiring a short‑lived code derived from a secret held by the user’s device. TOTP (RFC 6238) is widely supported, works offline, and integrates with common authenticator apps (Google Authenticator, Microsoft Authenticator, Authy, and hardware like YubiKey in HOTP/TOTP mode).
For remote desktop scenarios you should care about two different protections:
- Account-level 2FA (your vendor/account portal login) — prevents attackers stealing your cloud account that controls devices and permissions.
- Session or host-level 2FA (gateways/host logons) — prevents direct RDP sessions or unattended access if a host password is compromised.
Cloud services (TeamViewer, AnyDesk) typically provide account-level TOTP by default; RDP requires an additional layer (Duo, Azure AD MFA, NPS extension, or third‑party PAM) to protect the host session.
TOTP basics you need to know before starting
TOTP generates time-based 6‑digit codes (commonly) every 30 seconds using a shared secret and the current time. Key operational points:
- Code length: usually 6 digits. Some systems support 8 digits but 6 is the most common.
- Time step: typically 30 seconds. Implementations tolerate a small clock drift (±1 step).
- Secret storage: the TOTP secret (the QR/secret key) is the critical secret. Treat it like a password — if it’s leaked, that account is compromised.
- Backup codes: generate and store backup/recovery codes offline (paper safe or password manager) in case the device is lost.
- Authenticator apps: Google Authenticator, Microsoft Authenticator, Authy work fine. Hardware tokens (YubiKey in OATH mode) are preferable for high security.
Make sure devices running authenticators have accurate time. On phones this is normally automatic; for servers use NTP (ntpd/chrony) to avoid failing TOTP checks.
TeamViewer: enable account TOTP (quick, built‑in)
TeamViewer provides two‑factor authentication for your TeamViewer account. This secures the account that manages devices, connection logs, and unattended access policies.
Steps (TeamViewer desktop or web account):
- Open your browser and go to https://login.teamviewer.com or open the TeamViewer client and click your account avatar → Manage account.
- Go to the 'Security' or 'Two‑factor authentication' section.
- Click 'Enable' for Two‑factor authentication. TeamViewer will display a QR code and a 16‑character secret you can copy.
- Open an authenticator app (Google Authenticator, Authy, Microsoft Authenticator), add a new account, and scan the QR code or paste the secret.
- Enter the 6‑digit TOTP code shown in the app to confirm and finalise the setup. TeamViewer will offer recovery codes — store these securely.
Notes and gotchas: TeamViewer supports push approvals for some flows, but TOTP remains the fallback and is more portable. If you use TeamViewer for unattended access, remember that enabling account 2FA does not replace per‑device access control or local device passwords. TeamViewer's account 2FA stops attackers from changing settings or adding trusted devices, which is often the most important step.
AnyDesk: enabling two‑step verification / TOTP
AnyDesk offers two‑factor authentication for AnyDesk accounts and recently expanded security features in the 7.x series. The process is similar to TeamViewer: enable 2FA on the account and use an authenticator app to produce TOTP codes.
Steps (AnyDesk client or my.anydesk.com):
- Sign into your AnyDesk account at https://my.anydesk.com or open the AnyDesk client and sign in.
- Navigate to Profile → Security or 'Two‑Step Verification'.
- Choose 'Enable', scan the presented QR with your authenticator app (or enter the shared secret manually), and confirm by entering a valid 6‑digit code.
- Store any provided recovery codes in a secure location.
Notes: AnyDesk’s account 2FA prevents attackers from accessing your list of devices and changing permissions. AnyDesk also has per‑device security settings (unattended access password, access control lists); use those alongside account 2FA. In workflows where AnyDesk is primarily used for remote support, account‑level 2FA prevents misuse of your account rather than protecting each host connection — consider pairing account 2FA with per‑host controls.
Microsoft RDP: adding TOTP to host logons (the harder, but necessary, case)
Vanilla Microsoft RDP (the RDP protocol on Windows 10/11/Windows Server) does not natively support TOTP for interactive logon. To add 2FA/TOTP to RDP sessions you must insert an authentication provider in the logon path. Common choices:
- Cisco Duo: Duo provides a Windows Logon/RDP integration that supports TOTP, push, phone call, or hardware tokens. Duo installs a credential provider on the Windows host. See Duo’s documentation for 'Duo for Windows Logon and RDP'.
- Azure AD + Conditional Access + MFA: If your machines are Azure AD‑joined or using Azure AD Domain Services, you can require Azure AD MFA for remote access via RD Gateway or Windows Virtual Desktop. Azure MFA typically uses push notifications but can also use OATH TOTP via Microsoft Authenticator.
- NPS Extension for Azure MFA: for RD Gateway/NPS setups, Microsoft’s NPS extension integrates Azure MFA with RADIUS NPS, enabling MFA on gateway authentication.
- Free/Open options: you can deploy a RADIUS server (FreeRADIUS) and a PAM or RADIUS TOTP plugin (eg. Google Authenticator PAM or freeradius‑oath) in front of an RD Gateway. This requires more sysadmin work but keeps everything on‑prem and supports standard HOTP/TOTP tokens.
Example: Duo for Windows Logon (high‑level steps)
- Create an application in the Duo Admin Panel and note the integration key, secret key, and API hostname.
- Download the 'Duo Authentication for Windows Logon' installer and run it on the target host (Windows 10/11/Server 2016+ supported in recent Duo builds).
- During installer configuration, enter the integration key/secret/API hostname. Choose whether to require Duo for console logon, RDP, or both.
- Users enroll in Duo and can use the Duo Mobile app (TOTP is available via Duo's OATH tokens) or hardware tokens.
Notes and limitations: Requiring 2FA at the host level can complicate automated tasks and service accounts — make sure you exempt service accounts and use separate service credentials or machine certificates. Also keep an emergency break‑glass account secured offline without 2FA to recover access if 2FA infrastructure fails.
Self‑hosted remote desktop (GoDesk and others): how to implement TOTP
Self‑hosted solutions give you the most flexibility but also the responsibility. GoDesk (open‑source remote desktop) can be deployed self‑hosted or used via a managed option — either way, applying 2FA follows two fronts: the web/account portal and the host agent.
Account portal 2FA: If you're using a hosted control plane, enable account 2FA in the portal (scan a QR, enter code, store recovery codes). For self‑hosted control planes, you can add TOTP by integrating an identity provider that supports TOTP (Keycloak, Authelia) or by adding a TOTP crate/library if you maintain the portal yourself.
Host‑level 2FA: For self‑hosted agents, protect unattended access by requiring a strong local password and pairing it with an external gateway that forces 2FA. Options:
- Place your GoDesk servers behind an RD Gateway or VPN that requires MFA.
- Use an identity broker (Keycloak, Dex) with TOTP enabled and configure GoDesk to require authentication via that broker.
- On Linux hosts, enforce PAM TOTP (libpam-google-authenticator) for desktop sessions; combine with firewall rules so remote desktop is only reachable via the authentication gateway.
If you run GoDesk self‑hosted and want a practical how‑to, see our self‑hosted remote desktop guide: /self-hosted-remote-desktop-guide. To try the client or server, download builds at /download. If you’re evaluating pricing or managed offerings, see /pricing for current options and differences between self‑hosted and managed plans.
Best practices, recovery, and troubleshooting
Implementing TOTP is straightforward but common mistakes create lockouts or weak protection. Follow these pragmatic rules:
- Backup codes: Immediately save the recovery codes shown when you enable 2FA. Store them in a password manager (1Password, Bitwarden) or printed paper in a safe.
- Time sync: Ensure servers and phones have correct time. For servers use NTP (chrony/ntpd/systemd‑timesyncd). Authenticator apps rely on accurate time; mismatch will cause code failures.
- Fallback accounts: Keep one offline 'break glass' admin account protected physically (not registered to your primary phone) to recover if 2FA is lost — but minimise use of this account.
- Enforce device policies: Require hardware-backed authenticators (FIDO2/YubiKey) for privileged users where possible. They’re resistant to phishing compared with TOTP apps.
- Audit and logging: Log authentication failures and 2FA events. If an account suddenly needs many recovery code uses, treat that as a compromise.
- Avoid SMS-based 2FA for remote desktop access; SMS is vulnerable to SIM swapping and interception.
Common troubleshooting steps
- Codes not accepted: check time on both client and server, and check that you're using the right account/secret. Try ±1 time step if the system allows a window.
- Lost authenticator device: use stored recovery codes to disable 2FA and re‑enroll a new device. If you don't have recovery codes, contact the vendor’s account recovery (expect verification challenges and delays).
- Service accounts: don't use 2FA on service accounts that need unattended logon; instead, use machine certificates, managed identities, or a dedicated service account with tightly limited permissions.
When a competitor is simpler — and when RDP still needs help
Honest assessment: cloud products like TeamViewer and AnyDesk make enabling account TOTP trivial — built into the account portal with QR codes and recovery codes. If all you need is to protect the account that oversees devices, that can be the fastest, most effective step. Where they fall short is host‑level enforcement: if someone already has local credentials on a machine, account 2FA won't necessarily block a direct RDP session unless you also lock down unattended access on the machine.
RDP, especially in on‑prem environments, requires additional components (Duo, Azure MFA, NPS extension, PAM/RADIUS) to get host logons protected by TOTP. That extra complexity is necessary for security — expect an install/config window of a few hours to a few days depending on your scale, certificate setup, and edge cases like service accounts.
Quick checklist before you turn on TOTP
- Decide scope: account-only vs host-level protection.
- Pick authenticator strategy: app TOTP (Authy/Google) vs hardware (YubiKey/FIDO2) for privileged users.
- Generate and store recovery codes in a secure vault before testing.
- Sync clocks (NTP) across servers and critical infrastructure.
- Plan how to handle lost devices: documented recovery flow, break‑glass process, and support contact.
If you want step‑by‑step help with self‑hosting or integrating MFA into your remote access architecture, we’ve written a broader piece on remote desktop security that covers threat models and network controls: /remote-desktop-security. For hands‑on instructions for self‑hosted deployments, see our guide at /self-hosted-remote-desktop-guide.
Two‑factor authentication with TOTP isn’t a silver bullet, but it’s one of the most cost‑effective protections you can add to a remote access workflow. Start with account TOTP on TeamViewer/AnyDesk, then plan a host‑level 2FA strategy for RDP or self‑hosted agents. If you’re ready to test a self‑hosted remote desktop or try GoDesk, download the client and server builds at /download and follow the setup steps — and consider pairing that with an identity broker or MFA gateway to enforce host logon TOTP.
Ready to try it yourself?
Free for 30 devices, no credit card. Up and connected in two minutes.