|
| 1 | +# SSH Workspaces |
| 2 | + |
| 3 | +cmux supports using an SSH remote to run workspaces. When configured, all tool operations will |
| 4 | +execute over SSH and the agent is securely isolated from your local machine. |
| 5 | + |
| 6 | +We highly recommend using SSH workspaces for an optimal agentic experience: |
| 7 | + |
| 8 | +- **Security**: Prompt injection risk is contained to the credentials / files on the remote machine. |
| 9 | +- **Performance**: Run many, many agents in parallel while maintaining good battery life and UI performance |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +The Host can be: |
| 14 | + |
| 15 | +- a hostname (e.g. `my-server.com`) |
| 16 | +- a username and hostname (e.g. `[email protected]`) |
| 17 | +- an alias from your `~/.ssh/config`, e.g. `my-server` |
| 18 | + |
| 19 | +In fact, we delegate SSH configuration to the system's `ssh` command, so can set up advanced |
| 20 | +configuration for your agentic machine in your local `~/.ssh/config` file. |
| 21 | + |
| 22 | +Here's an example of an alias: |
| 23 | + |
| 24 | +``` |
| 25 | +Host ovh-1 |
| 26 | + HostName 148.113.1.1 |
| 27 | + User root |
| 28 | +``` |
| 29 | + |
| 30 | +## Authentication |
| 31 | + |
| 32 | +> **Note**: As we delegate to `ssh`, this is really an abbreviated reference of how `ssh` authenticates. |
| 33 | +
|
| 34 | +There are a few practical ways to set up authentication. |
| 35 | + |
| 36 | +### Local defaults |
| 37 | + |
| 38 | +Ensure your private key is one of these locations: |
| 39 | + |
| 40 | +``` |
| 41 | +~/.ssh/id_rsa |
| 42 | +~/.ssh/id_ecdsa |
| 43 | +~/.ssh/id_ecdsa_sk |
| 44 | +~/.ssh/id_ed25519 |
| 45 | +~/.ssh/id_ed25519_sk |
| 46 | +``` |
| 47 | + |
| 48 | +### SSH Agent |
| 49 | + |
| 50 | +If you have an SSH agent running, you can use it to authenticate. |
| 51 | + |
| 52 | +``` |
| 53 | +ssh-add ~/.ssh/id_rsa |
| 54 | +``` |
| 55 | + |
| 56 | +### Config |
| 57 | + |
| 58 | +You can also configure authentication in your `~/.ssh/config` file. |
| 59 | + |
| 60 | +``` |
| 61 | +Host my-server |
| 62 | + HostName 148.113.1.1 |
| 63 | + User root |
| 64 | + IdentityFile ~/.ssh/id_rsa |
| 65 | +``` |
| 66 | + |
| 67 | +## Coder Workspaces |
| 68 | + |
| 69 | +If you're using [Coder Workspaces](https://coder.com/docs), you can leverage your existing Workspace |
| 70 | +with cmux: |
| 71 | + |
| 72 | +1. Run `coder config-ssh` |
| 73 | +2. Use `coder.<workspace-name>` as your SSH host when creating a new cmux workspace |
| 74 | + |
| 75 | +Note that in this approach we're multiplexing agents onto a single Coder Workspace, not creating |
| 76 | +a new workspace per agent. This avoids the workspace creation overhead for rapid muxing, |
| 77 | +while still isolating the agent from your local machine. |
0 commit comments