Skip to main content

Overview

The netbird login command authenticates your device with the NetBird management server without establishing network connections. Use this to authenticate before connecting with netbird up.

Description

This command performs authentication only:
  1. Initiates SSO authentication flow (if no setup key provided)
  2. Validates credentials with the management server
  3. Stores authentication tokens locally
  4. Does NOT bring up the WireGuard interface
  5. Does NOT establish peer connections
Use netbird up after login to connect to the network, or use netbird up directly (which includes login if needed).

When to Use Login vs Up

Use netbird login when:

  • You want to authenticate without connecting immediately
  • Pre-authenticating in preparation for later connection
  • Testing authentication credentials
  • Separating authentication from connection in automation scripts

Use netbird up when:

  • You want to authenticate AND connect in one step (most common)
  • Starting NetBird for normal use

Flags

string
Profile name to use for the login. If not specified, the last used profile will be used.
boolean
default:"false"
Do not open the browser for SSO loginWhen enabled, displays the authentication URL for manual browser access. Useful for:
  • Headless servers
  • SSH sessions
  • Automated environments
  • Remote systems
All global flags are also available, including:
  • --setup-key - Authenticate with a setup key instead of SSO
  • --management-url - Specify management server URL
  • --hostname - Set custom hostname

Examples

Interactive SSO Login

Login with SSO (opens browser):
Output:

Login Without Browser (Headless)

For servers or SSH sessions:
Output:
Open the URL on another device to complete authentication.

Login with Setup Key

Non-interactive authentication using a setup key:
Output:

Login to Self-Hosted Management Server

Login with Custom Hostname

Login to Specific Profile

Environment Variable Authentication

Use environment variables for automation:

Authentication Methods

SSO (Single Sign-On)

Default authentication method for interactive sessions: Supported SSO Providers:
  • Google
  • Microsoft Azure AD / Entra ID
  • Okta
  • Auth0
  • Keycloak
  • Other OIDC providers
Flow:
  1. Run netbird login
  2. Browser opens to SSO provider
  3. Login with your SSO credentials
  4. Browser redirects back with success message
  5. NetBird stores authentication token
Headless SSO:
Copy the displayed URL to a browser on any device.

Setup Key

Non-interactive authentication for automation:
Setup key features:
  • Created in Management Dashboard
  • Can be reusable or one-time use
  • Can have expiration dates
  • Can auto-assign to groups
  • Ideal for scripting and automation
Generate setup keys:
  1. Log into NetBird Management Dashboard
  2. Navigate to Setup Keys
  3. Click “Add Key”
  4. Configure key properties
  5. Copy the generated key
See: Register Machines Using Setup Keys

Login Flow

Daemon Mode (Default)

When the NetBird daemon is running:
Authentication is handled by the daemon service.

Foreground Mode

Without daemon (standalone authentication):
If log files are not configured, runs in standalone mode.

Profile Management

NetBird supports multiple profiles for different networks or accounts:

Login to Specific Profile

Switch Profile During Login

If currently connected, will disconnect first:

Create Profile and Login

Profiles are created automatically on first login:
For profile management, use the --profile flag

Status Messages

  • Logging successfully - Authentication completed successfully
  • login failed - Authentication failed (check credentials or setup key)
  • failed to connect to daemon - NetBird daemon not running
  • NeedsSSOLogin - SSO authentication required

Common Issues

Daemon Not Running

Solution:

Browser Not Opening

If browser doesn’t open automatically:
  1. Copy the displayed URL
  2. Open it manually in a browser
  3. Complete authentication
Or use --no-browser explicitly:

Invalid Setup Key

Causes:
  • Key has expired
  • Key was deleted
  • Key is one-time use and already consumed
  • Typo in key value
Solution: Generate a new setup key in the Management Dashboard

Authentication Timeout

If SSO authentication times out:
  1. Run netbird login again
  2. Complete authentication more quickly
  3. Check network connectivity

Session Already Exists

If already logged in:

Security Considerations

Token Storage

Authentication tokens are stored securely in:
  • Linux: /etc/netbird/config.json
  • macOS: /etc/netbird/config.json
  • Windows: %PROGRAMDATA%\Netbird\config.json
Permissions:
  • File should be readable only by root/administrator
  • Contains sensitive authentication data
  • Do not share or commit to version control

Setup Key Security

Best practices:
  • Use one-time keys for automated provisioning
  • Set expiration dates on keys
  • Delete unused keys
  • Use different keys for different environments
  • Never commit keys to source control
  • Use environment variables or secret managers
Environment variable example:

Automation Examples

Docker/Container Init

CI/CD Pipeline

Terraform/Ansible

See Also