CLI SSH Authentication (macOS)

View as Markdown

This guide helps you resolve Brev CLI authentication failures on macOS when SSH key issues prevent connection to your instances.

Platform: macOS

Problem

On macOS systems, Brev CLI commands such as brev ls, brev login, or brev ssh fail with authentication or connection errors.

Typical symptoms include:

  • Permission denied (publickey)
  • Could not establish SSH connection
  • Error: connection closed unexpectedly

This issue occurs when the local SSH key used by Brev (~/.brev/brev.pem) becomes invalid, corrupted, or has incorrect file permissions.

Prerequisites

  • macOS with Brev CLI installed (brew install brevdev/homebrew-brev/brev)
  • Access to Brev dashboard or web app
  • Terminal access with user home directory permissions

Solution

Choose one of the following approaches to resolve the issue.

1

Open account settings

Go to Brev Dashboard → Account Settings: https://brev.nvidia.com/settings/account

3

Copy the token

Copy the authentication token displayed on the page.

4

Authenticate in terminal

Paste the token in your terminal when prompted by:

$brev login --token
5

Verify connection

$brev ls

The command should list all available instances without error.

Option 2: Regenerate SSH Key

1

Check for existing Brev key

$ls -l ~/.brev/brev.pem

If the file is missing or has incorrect permissions, proceed to the next step.

2

Backup and remove old key

$mv ~/.brev/brev.pem ~/.brev/brev.pem.bak
3

Generate a new Brev key

  1. Go to the Brev Dashboard
  2. Navigate to Profile → SSH Keys
  3. Re-download or generate a new .brev.pem file
4

Set correct file permissions

$chmod 600 ~/.brev/brev.pem
5

Re-authenticate with Brev

$brev login
$brev ls

Verify the connection is successful.

Verification

After completing either option:

  • brev ls lists all available instances without error
  • brev ssh <instance-name> connects successfully to the instance
  • No permission or key errors appear in terminal output

Workaround

If key regeneration fails:

  • Temporarily use the Brev Web Dashboard for instance access
  • Restore the previous key if needed:
$mv ~/.brev/brev.pem.bak ~/.brev/brev.pem
$chmod 600 ~/.brev/brev.pem