# Connect Cursor or VS Code with Remote-SSH

Connect Cursor or VS Code to an arvm Ubuntu 24.04 VM over standard SSH so language servers, tests, and Docker containers run in the cloud while your editor stays local.

## 1. Create a VM and install SSH config

Create a machine with an idle timeout that matches your work blocks, then let `arvm ssh-config --install` add the host entry to `~/.ssh/config`.

```console
$ arvm new --idle-timeout 4h
$ arvm ssh-config --install
```

The examples below use `calm-river-otter`. Replace it with the name `arvm new` prints. `arvm ssh-config --install` registers your SSH public key, pins the gateway's host key in arvm's `known_hosts` file, and keeps entries updated when you create, rename, or delete machines.

## 2. Connect from Cursor or VS Code

1. Install the **Remote - SSH** extension in Cursor or VS Code.
2. Open the Command Palette and run **Remote-SSH: Connect to Host**.
3. Pick `calm-river-otter` from the host list.
4. Open `/home/dev` or clone your repository inside the integrated terminal.

Because each machine keeps its SSH address across stops and starts, the same host entry works every time you wake the machine.

## 3. Preview dev servers over HTTPS or SSH

Start your development server inside the VM (for example on port 3000), then choose either a private HTTPS URL or a local port forward.

To open the app from any browser behind a signed HTTPS link:

```console
$ arvm expose calm-river-otter 3000
```

`arvm expose` prints a private `signed_url` that requires its token on first visit. Pass `--public` only when you want anyone on the internet to reach the port, and close the URL when finished:

```console
$ arvm unexpose calm-river-otter 3000
```

For non-HTTP ports such as Postgres or Redis, forward the port to your computer over SSH instead:

```console
$ arvm forward calm-river-otter 5432
```

## 4. Stop the VM when you finish

Close your Remote-SSH window and stop the machine:

```console
$ arvm stop calm-river-otter
```

Before reconnecting the next day, run `arvm start calm-river-otter` (plain SSH from an editor does not wake a stopped VM).

## Idle stop and billing

A `default` VM (4 vCPUs, 8 GB RAM, 51 GB disk) costs $0.018 an hour, or $13.14 for a full month. Running one VM for 8 hours a day across 22 workdays is 176 hours, which uses $3.17 of the $20 plan. Stopped machines cost $0 and keep your editor server cache, dependencies, and repositories on disk.

Open Remote-SSH sessions and HTTPS endpoint requests count as gateway activity and reset the idle timer. Once you close your editor window, idle stop shuts down the VM after its timeout. See [Idle stop](../machines.md#idle-stop) and [Public URLs](../public-urls.md).

Machine disks are not backed up. Keep your code pushed to Git.

## Troubleshooting

| Symptom | What to do |
|---|---|
| Remote-SSH connection hangs or closes immediately | Plain SSH does not start a stopped machine. Run `arvm start calm-river-otter`, wait until it is running, and reconnect. |
| `calm-river-otter` is missing from the Remote-SSH host list | Run `arvm ssh-config --install` and confirm `~/.ssh/config` contains the `Include` line at the top. |
| Exposed HTTPS URL returns 401 | A new endpoint is private. Open the `signed_url` printed by `arvm endpoints calm-river-otter` once to set the session cookie. |
| Language server or build runs out of memory | Stop the VM, run `arvm resize calm-river-otter large` (8 vCPUs, 16 GB RAM, 111 GB disk), and run `arvm start calm-river-otter`. |

## Related guides

- [Use Rex with a cloud Linux VM](rex.md)
- [Use OpenCode and OpenCode Desktop over SSH](opencode-desktop.md)
- [Connect over SSH](../connect.md)
- [Public URLs](../public-urls.md)
