Overview
2FA in Dokploy uses the TOTP standard (RFC 6238), which is compatible with popular authenticator apps like:- Google Authenticator (iOS, Android)
- Microsoft Authenticator (iOS, Android)
- Authy (iOS, Android, Desktop)
- 1Password (with built-in authenticator)
- Bitwarden (with built-in authenticator)
- Any TOTP-compatible authenticator app
Dokploy uses the industry-standard TOTP algorithm, ensuring compatibility with virtually all authenticator apps on the market.
How 2FA Works
Enabling 2FA
For Individual Users
Find Two-Factor Authentication Section
Locate the Two-Factor Authentication section in your security settings
Scan QR Code
A QR code will appear on screen:
- Open your authenticator app
- Tap the + or add account button
- Scan the QR code displayed in Dokploy
Can’t scan? Click Manual Entry to see the secret key and enter it manually into your authenticator app.
Save Recovery Codes
Dokploy will display a set of recovery codes:
- Download and save these codes securely
- You’ll need these if you lose access to your authenticator
- Each code can only be used once
QR Code Format
The QR code contains a URL in this format:- Protocol:
otpauth://totp/ - Label:
Dokploy:user@example.com(distinguishes this account in your app) - Secret: Base32-encoded secret key shared between Dokploy and your app
- Issuer:
Dokploy(appears as the service name in your authenticator)
Signing In with 2FA
Once 2FA is enabled:Codes are time-based and refresh every 30 seconds. If a code doesn’t work, wait for the next code to appear and try again.
Recovery Codes
Recovery codes are backup codes you can use if you lose access to your authenticator app.What Are Recovery Codes?
- One-time use: Each code can only be used once
- Backup authentication: Use them if you don’t have your authenticator device
- Typically 8-10 codes: You receive multiple codes when enabling 2FA
- Format: Usually 8-10 alphanumeric characters
Using a Recovery Code
Viewing Recovery Codes
To view your remaining recovery codes:Regenerating Recovery Codes
If you’ve used most of your recovery codes or want to invalidate old ones:Disabling 2FA
To disable two-factor authentication:Disabling 2FA removes the requirement for authentication codes but does not delete your recovery codes. If you re-enable 2FA, you’ll need to scan a new QR code.
Lost Authenticator Access
If you lose access to your authenticator device:Option 1: Use Recovery Code
- Sign in with your email and password
- Click Use a recovery code instead
- Enter one of your saved recovery codes
- Once signed in, set up 2FA again with a new device
Option 2: Contact Administrator (Organization Members)
If you don’t have recovery codes:- Contact your organization owner or administrator
- They can disable 2FA for your account from the user management panel
- Sign in with just your password
- Set up 2FA again with a new authenticator
Option 3: Account Recovery (Organization Owners)
Organization owners who lose both authenticator and recovery codes may need to:- Contact Dokploy support (for Dokploy Cloud)
- Access the database directly (for self-hosted instances) to disable 2FA
- This is a last resort and requires proof of identity
Security Best Practices
Enable 2FA for All Users
Organization administrators should:- Encourage or require 2FA for all team members
- Especially for users with admin or owner roles
- Consider making 2FA mandatory for production environments
Currently, Dokploy allows individual users to enable 2FA voluntarily. Organization-wide 2FA enforcement may be added in future versions.
Secure Your Recovery Codes
- Don’t store with authenticator: Keep codes separate from your device
- Use a password manager: Store codes in a secure vault
- Print and store physically: Keep a printed copy in a safe location
- Never share codes: Recovery codes are as sensitive as passwords
Choose a Reliable Authenticator
- Cloud backup: Use apps that support encrypted cloud backup (Authy, 1Password)
- Multiple devices: Consider apps that sync across devices
- Offline capable: Ensure your authenticator works without internet access
Regular Security Audit
- Review accounts with 2FA enabled
- Regenerate recovery codes periodically
- Remove 2FA for accounts that are no longer active
Time Synchronization
TOTP codes are time-based, so accurate time synchronization is critical:Client Device (Your Phone/Computer)
- Ensure your device’s clock is set to automatic time
- Use network time protocol (NTP) for accuracy
- Codes may not work if your device clock is off by more than 30 seconds
Server (Dokploy)
- Dokploy servers must have accurate time synchronization
- Self-hosted instances should use NTP
- Cloud instances are automatically time-synchronized
If you consistently get “invalid code” errors, check your device’s time settings. Even a few seconds of drift can cause codes to fail.
Troubleshooting
”Invalid Code” Error
Time synchronization issue- Check that your device time is set to automatic
- Wait for the next code (codes refresh every 30 seconds)
- Try the code immediately after it refreshes
- Verify you’re looking at the correct entry in your authenticator app
- Check that the account label matches your Dokploy email
- Codes expire after 30 seconds
- Don’t enter a code that’s about to expire
- Wait for a fresh code to appear
QR Code Won’t Scan
Camera issues- Ensure your authenticator app has camera permissions
- Try better lighting
- Hold your device steady
- Click Can’t scan QR code? or Manual entry
- Copy the secret key and paste it into your authenticator
- Make sure to copy the entire key (case-insensitive)
Lost Recovery Codes
If you’ve lost your recovery codes but still have authenticator access:- Sign in to Dokploy
- Go to Security Settings
- Click View Recovery Codes or Regenerate Recovery Codes
- Save the new codes securely
Account Locked Out
If you’ve lost both your authenticator and recovery codes: Organization members:- Contact your organization owner or administrator
- They can disable 2FA for your account
- Contact Dokploy support (Cloud) or access your database (self-hosted)
- This process requires identity verification
Technical Implementation
Dokploy’s 2FA implementation uses:- Algorithm: TOTP (Time-Based One-Time Password) per RFC 6238
- Hash Function: SHA-1 (standard for TOTP)
- Time Step: 30 seconds (standard)
- Code Length: 6 digits
- Window: Accepts codes from previous and next time steps (±1 window)
Database Storage
When you enable 2FA:- Secret: Encrypted and stored in the database
- Recovery Codes: Hashed before storage (like passwords)
- Enabled Flag:
twoFactorEnabledboolean field
Authentication Flow
API Integration
Dokploy uses the Better Auth library’s twoFactor plugin for 2FA functionality:2FA is a user-level feature, not organization-level. Each user manages their own 2FA settings independently.
Compliance and Standards
Dokploy’s 2FA implementation complies with:- RFC 6238: TOTP: Time-Based One-Time Password Algorithm
- RFC 4226: HOTP: An HMAC-Based One-Time Password Algorithm
- NIST SP 800-63B: Digital Identity Guidelines (Authentication and Lifecycle Management)
- SOC 2 compliance requirements
- GDPR data protection requirements
- Industry security best practices
Next Steps
Single Sign-On
Configure enterprise SSO
API Keys
Generate API keys for automation
Notifications
Set up security notifications
Git Providers
Configure secure Git integration