CLI SSH Authentication (macOS)
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 connectionError: 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.
Option 1: Re-authenticate Using Token (Recommended)
Open account settings
Go to Brev Dashboard → Account Settings: https://brev.nvidia.com/settings/account
Option 2: Regenerate SSH Key
Check for existing Brev key
If the file is missing or has incorrect permissions, proceed to the next step.
Generate a new Brev key
- Go to the Brev Dashboard
- Navigate to Profile → SSH Keys
- Re-download or generate a new
.brev.pemfile
Verification
After completing either option:
brev lslists all available instances without errorbrev 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: