Connectivity
Connect to your instances through shell, VS Code, or port forwarding.
SSH is fully managed: The Brev CLI tracks instance hostnames and IP addresses automatically. Connect by instance name (ssh my-instance or brev shell my-instance) - you never need to look up or remember IP addresses.
brev shell
Open an interactive SSH shell on your instance. Alias: ssh
This command opens an SSH connection to your instance. You’ll land in /home/ubuntu/workspace.
Flags
brev open
Open your instance in VS Code, Cursor, Windsurf, or tmux.
Supported Editors
Flags
brev port-forward
Forward ports from your instance to localhost. Essential for accessing Jupyter, web servers, and other services.
How Port Forwarding Works
Port forwarding creates a secure tunnel from your local machine to your instance. The local:remote format means:
- Local port: The port on your machine (where you access the service)
- Remote port: The port on your instance (where the service runs)
For example, --port 8888:8888 forwards localhost:8888 to instance:8888.
If a local port is already in use, choose a different local port: --port 9999:8888 forwards localhost:9999 to instance:8888.
Flags
Common Port Forwards
Direct SSH
You can also connect directly with SSH using the Brev-managed key:
Where:
~/.brev/brev.pemis your Brev private keyLOCAL_PORTis the port on your local machineREMOTE_PORTis the port on your Brev instance<instance-ip>is your instance’s public IP address
SSH config: Running brev refresh updates ~/.brev/ssh_config with your instance details. This file is included from ~/.ssh/config so you can connect by instance name.
Using Tunnels (Web Console)
For publicly accessible URLs, use Brev’s tunnel feature through the web console. This creates a shareable URL for your service.
Important Tunnel Limitations:
- Tunnels route through Cloudflare for authentication
- First access requires browser authentication (redirect)
- For direct API access without browser authentication, use
brev port-forwardinstead
When to Use Tunnels vs Port Forwarding
IP Address Changes
Instance IP addresses are stable while an instance is running. However, when you stop and restart an instance, it may receive a new IP address.
The CLI handles this automatically - run brev refresh after restarting an instance to update your local SSH config with the new IP.
This command:
- Fetches the latest IP addresses for all your instances
- Updates
~/.brev/ssh_configwith the new connection details - Ensures you can connect by instance name without knowing the IP
You only need to run brev refresh after stopping and restarting an instance. While an instance is running, its IP address remains the same.
You can verify the instance’s current public IP by SSHing in and running: