VibeTunnel Authentication System
VibeTunnel supports multiple authentication modes to balance security and convenience for different use cases.Authentication Modes
1. Default Mode (Password Authentication)
Usage: Start VibeTunnel without any auth flags- Shows login page with user avatar (on macOS)
- Requires system user password authentication
- Uses JWT tokens for session management
- SSH key functionality is hidden
2. SSH Key Mode
Usage: Enable SSH key authentication alongside password- Shows login page with both password and SSH key options
- Users can generate Ed25519 SSH keys in the browser
- SSH keys are stored securely in browser localStorage
- Optional password protection for private keys
- SSH keys work for both web and terminal authentication
3. SSH Keys Only Mode
Usage: Disable password authentication, SSH keys only- Shows login page with SSH key options only
- Password authentication form is hidden
- Automatically enables
--enable-ssh-keys
- User avatar still displayed with “SSH key authentication required” message
- Most secure authentication mode
4. No Authentication Mode
Usage: Disable authentication completely- Bypasses login page entirely
- Direct access to dashboard
- No authentication required
- Auto-logs in as current system user
- Overrides all other auth flags
5. Tailscale Serve Integration Mode
Usage: Enable integrated Tailscale Serve support- Automatically starts
tailscale serve
as a background process - Forces server to bind to localhost (127.0.0.1) for security
- Enables Tailscale identity header authentication
- Provides HTTPS access without exposing ports
- No manual Tailscale configuration required
- Toggle available in Settings → Remote Access → Tailscale Integration
- Shows HTTPS URL in menu bar when enabled
- Automatically manages the Tailscale Serve process lifecycle
- Server only listens on localhost when enabled
- All external access goes through Tailscale’s secure proxy
- Identity headers are automatically validated
- No risk of header spoofing from external sources
User Avatar System
macOS Integration
On macOS, VibeTunnel automatically displays the user’s system profile picture:- Data Source: Uses
dscl . -read /Users/$USER JPEGPhoto
to extract avatar - Format: Converts hex data to base64 JPEG
- Fallback: Uses
Picture
attribute if JPEGPhoto unavailable - Display: Shows in login form with welcome message
Other Platforms
On non-macOS systems:- Displays a generic SVG avatar icon
- Maintains consistent UI layout
- No system integration required
Command Line Options
Server Startup Flags
Example Commands
Security Considerations
Password Authentication
- Uses system PAM authentication
- Validates against actual system user passwords
- JWT tokens expire after 24 hours
- Secure session management
SSH Key Authentication
- Generates Ed25519 keys (most secure)
- Private keys stored in browser localStorage
- Optional password protection for private keys
- Keys work for both web and terminal access
- Challenge-response authentication flow
No Authentication Mode
- ⚠️ Security Warning: Only use in trusted environments
- Suitable for local development or demo purposes
- Not recommended for production or public networks
Tailscale Authentication
- ⚠️ Security Warning: Only use when bound to localhost
- Requires Tailscale Serve proxy for header injection
- Provides SSO-like experience for Tailscale users
- Headers are trusted only from Tailscale proxy
Configuration API
Frontend Configuration Endpoint
The frontend can query the server’s authentication configuration:- Show/hide SSH key options dynamically
- Hide password form when disallowed
- Skip login page when no-auth is enabled
- Adapt interface based on server configuration
SSH Key Management
Key Generation Process
- Algorithm: Ed25519 (most secure and modern SSH key type)
- Browser Implementation: Uses Web Crypto API for secure key generation
- Storage: Browser localStorage (optionally encrypted with user password)
- Format: PEM format for compatibility with standard SSH tools
- Naming: User-defined names for organization
- Browser generates Ed25519 key pair using
crypto.subtle.generateKey()
- Private key optionally encrypted with user-provided password
- Public key formatted in SSH wire format for server validation
- Keys stored in browser localStorage with unique identifiers
Key Import
- Supports importing existing Ed25519 private keys
- PEM format required (
-----BEGIN OPENSSH PRIVATE KEY-----
) - Automatic detection of password-protected keys
- Validation and error handling for malformed keys
- Compatibility with keys generated by
ssh-keygen -t ed25519
SSH Key Authentication Flow
Challenge-Response Process:- Challenge Request: Client requests authentication challenge from
/api/auth/challenge
- Challenge Generation: Server creates 32-byte random challenge with 5-minute expiry
- Key Selection: Client selects appropriate SSH key from browser storage
- Signature Creation: Browser signs challenge using private key via Web Crypto API
- Signature Submission: Client sends signed challenge to
/api/auth/ssh-login
- Server Verification:
- Server parses SSH public key wire format
- Validates signature using Node.js crypto module
- Checks public key against user’s
~/.ssh/authorized_keys
- Issues JWT token upon successful verification
- Server reads
~/.ssh/authorized_keys
file for target user - Validates submitted public key is present in authorized keys
- Supports both current user and other system users
- Handles standard SSH authorized_keys format
Key Setup Instructions
For Users:- Generate SSH key in VibeTunnel web interface
- Download public key file
- Add to server’s authorized_keys:
- Test authentication through VibeTunnel login
- Use password protection for private keys in shared environments
- Regularly rotate SSH keys (recommended: every 90 days)
- Remove unused keys from authorized_keys
- Monitor authentication logs for suspicious activity
Tailscale Authentication Details
How Tailscale Serve Works
Tailscale Serve acts as a reverse proxy that:- Receives requests from your tailnet
- Adds identity headers based on the authenticated Tailscale user
- Forwards requests to your local service
Identity Headers
When a request comes through Tailscale Serve, these headers are added:tailscale-user-login
: The user’s email address or logintailscale-user-name
: The user’s display nametailscale-user-profile-pic
: URL to the user’s profile picture
Setup Instructions
-
Start VibeTunnel with integrated Tailscale Serve:
Or use the macOS app and enable the toggle in Settings → Remote Access
-
Access via Tailscale:
Security Model
- VibeTunnel trusts identity headers ONLY from localhost connections
- Tailscale Serve ensures headers cannot be spoofed by external users
- Direct access to VibeTunnel port would allow header forgery
- Always bind to
127.0.0.1
when using Tailscale authentication
Integration with Other Auth Modes
Tailscale Serve integration can be combined with other authentication modes:--enable-tailscale-serve
flag automatically manages both the Tailscale proxy and authentication.
Implementation Details
Authentication Flow
- Server startup determines available auth modes
- Frontend queries
/api/auth/config
for configuration - UI renders appropriate authentication options
- User authenticates via chosen method
- JWT token issued for session management
- Subsequent requests use Bearer token authentication
Avatar Implementation
File Structure
Troubleshooting
Common Issues
Login page shows briefly then disappears (no-auth mode)- This is expected behavior - the page quickly redirects to dashboard
- Ensure server started with
--enable-ssh-keys
flag - Check browser console for configuration loading errors
- macOS only feature - other platforms show generic icon
- Check user has profile picture set in System Preferences
- Verify system password is correct
- Check server logs for detailed error messages
- Ensure proper permissions for PAM authentication
Debug Mode
Enable debug logging for detailed authentication flow:- Authentication attempts
- Token validation
- SSH key operations
- Configuration loading