Connectivity
Connect to your instances through shell, VS Code, or port forwarding. brev shell and brev port-forward also support Brev Connect machines after SSH is enabled and your Brev user has been granted access. Run connection commands on your local computer, use brev login with your user account, and select the machine’s organization with brev org set <organization-name>.
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. Managed instances use the workspace directory; Brev Connect machines use the Linux account associated with your SSH access grant.
Flags
brev exec
Run a command on one or more instances without opening an interactive shell.
Quote the whole command. Everything before the final argument is treated as an instance name, so brev exec my-instance python train.py looks for an instance named python. Write brev exec my-instance "python train.py" instead.
Flags
brev open
Open your instance in VS Code, Cursor, Windsurf, or tmux.
Supported Editors
Flags
brev port-forward
Forward a TCP port from your instance or Brev Connect machine to localhost over SSH. Start Jupyter, your web server, or another service on the remote port first.
Use one command per port mapping. Repeating --port in the same command only uses the last value; UDP forwarding is not supported by this SSH command.
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.
For Brev Connect machines, the command also creates a remote TCP port binding that persists after local forwarding exits. Remove an unneeded binding with the beta command brev ports close <machine-name>, selecting its destination port.
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 configuration generated by Brev. This preserves the correct username, endpoint, port, and authentication settings, including certificates for Brev Connect machines.
Where:
LOCAL_PORTis the port on your local machineREMOTE_PORTis the port on your Brev instancemy-instanceis the SSH alias generated for your instance or Brev Connect machine
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: