Documentation Index
Fetch the complete documentation index at: https://mintlify.com/karanhudia/borg-ui/llms.txt
Use this file to discover all available pages before exploring further.
Security Best Practices
Secure your Borg UI installation with authentication, SSH key management, and encryption.Authentication Methods
Borg UI supports two authentication modes: JWT-based authentication (default) and Reverse Proxy authentication (for SSO/enterprise setups).JWT Authentication (Default)
How it works:- Users authenticate with username/password
- JWT tokens are issued with configurable expiration (default: 24 hours)
- Tokens use HS256 algorithm with secret key encryption
- Passwords are hashed using bcrypt (salt rounds: 12)
app/core/security.py:18-39):
- Default admin account is created automatically on first run
- Username:
admin - Password:
admin123(or set viaINITIAL_ADMIN_PASSWORDenvironment variable) - Must change password on first login (enforced by
must_change_passwordflag)
Reverse Proxy Authentication
Use case: Integrate with existing SSO systems (Authelia, Authentik, Keycloak, etc.) Configuration:app/core/security.py:97-169):
- Borg UI trusts the
X-Forwarded-Userheader from reverse proxy - Users are auto-created on first access (no manual setup required)
- Alternative headers are checked:
X-Remote-User,Remote-User,X-authentik-username,X-Forwarded-User - If no header is present, defaults to
adminuser (for direct access)
- Configured header (
PROXY_AUTH_HEADER) X-Remote-UserRemote-UserX-authentik-usernameX-Forwarded-User
Secret Key Management
TheSECRET_KEY is used for JWT signing and data encryption (SSH keys, repository passwords).
Auto-Generation (Recommended)
Default behavior (fromapp/config.py:144-162):
- On first run, a cryptographically secure key is auto-generated
- Saved to
/data/.secret_keywith0600permissions - Reused across container restarts (persisted in volume)
Manual Configuration
Option 1: Environment variableSecret key length: Minimum 32 characters recommended. The system validates length in production mode (
app/config.py:183-187).Key Rotation
Warning: Rotating the secret key will:- Invalidate all existing JWT tokens (users must re-login)
- Make encrypted SSH keys unreadable (requires re-importing keys)
- Export all SSH keys before rotation
- Update
SECRET_KEYenvironment variable - Restart container
- Re-import SSH keys
- Notify users to re-login
SSH Key Security
Storage and Encryption
How SSH keys are stored (from documentation analysis):- Private keys are encrypted using Fernet symmetric encryption
- Encryption key derived from
SECRET_KEY(first 32 bytes) - Stored in SQLite database (
/data/borg.db) - Decrypted only during backup/mount operations (temporary files)
app/core/security.py:283-327):
SSH Key Types
Recommended: ED25519 (modern, smaller, faster)Deployment Security
Best practice: Use UI-based deployment- Go to Remote Machines → Deploy Key to Server
- Enter password (used once for deployment)
- Password is not stored - only used to install public key
- Future connections use passwordless SSH key authentication
- Prevents shell access with the backup key
- Restricts borg operations to specific repository path
- Mitigates damage if key is compromised
Repository Encryption
Borg repositories should always use encryption to protect backup data.Encryption Modes
Recommended:repokey-blake2 (fastest, most secure)
keyfile-blake2 (key stored separately)
none
Passphrase Management
During repository creation:- Borg UI prompts for passphrase
- Passphrase is encrypted before storage in database
- Decrypted only during backup/restore operations
- Minimum 20 characters recommended
- Use password manager to generate strong passphrases
- Store passphrase separately from repository backups
keyfile mode, export and backup the key:
Network Security
Binding and Firewall
Internal network only:HTTPS/TLS
Use reverse proxy for TLS termination:Borg UI does not include built-in TLS. Always use a reverse proxy (Nginx, Caddy, Traefik) for HTTPS.
User Management
Creating Users
Via Web Interface:- Login as admin
- Go to Settings → Users
- Click Add User
- Set username, password, email
- Assign admin privileges if needed
- Minimum 8 characters (enforced client-side)
- Passwords are bcrypt-hashed before storage
- Salt rounds: 12 (from
app/core/security.py:21-27)
Admin Privileges
Admin users can:- Create/delete users
- Modify system settings
- Access all repositories
- View system logs
- Manage SSH connections
- Create their own repositories
- Run backups on owned repositories
- Browse and restore from owned repositories
- Manage their own schedules
User Deactivation
Disable user instead of deleting:- Settings → Users → Edit User
- Uncheck “Active”
- Save
- User cannot login
- Existing sessions are invalidated
- User data (repositories, schedules) is preserved
- Can be reactivated later
Security Hardening
Docker Security
Run as non-root user:File Permissions
Secure data directory:Database Security
Backup database regularly:Audit and Logging
Security Event Logging
Logged security events:- User authentication attempts (success/failure)
- User creation/deletion
- SSH key generation/deployment
- Repository access
- System setting changes
Failed Login Monitoring
Watch for authentication failures:Security Checklist
Production Deployment Checklist
Production Deployment Checklist
Authentication:
- Changed default admin password
- Created individual user accounts (no shared credentials)
- Disabled unused admin accounts
- Configured
SECRET_KEY(auto-generated or custom)
- Generated ED25519 system key
- Deployed keys with
borg serve --restrict-to-pathrestrictions - Verified SSH key permissions (600 for private, 644 for public)
- Documented key locations and backup procedures
- Enabled encryption (repokey-blake2 or keyfile-blake2)
- Set strong passphrases (20+ characters)
- Backed up keyfiles separately
- Tested repository recovery procedure
- Configured HTTPS via reverse proxy
- Bound to localhost or restricted network
- Configured firewall rules
- Tested access from expected networks only
- Running as non-root user (PUID/PGID configured)
- Data directory permissions secured (700)
- Database backups scheduled
- Log monitoring configured
- Updated to latest version
Related Documentation
SSH Keys Guide
Detailed SSH key setup and management
Configuration
Environment variables and system settings
Troubleshooting
Common security-related issues and solutions
Maintenance
Database backups and system maintenance