Files
OpenShell/examples/vscode-remote-sandbox.md

1.6 KiB

Open VSCode in a Sandbox

Connect VSCode to a running sandbox using the Remote - SSH extension so you get a full IDE experience inside the sandbox environment.

Prerequisites

  • A running openshell gateway (openshell gateway start)
  • VSCode with the Remote - SSH extension installed
  • The openshell CLI on your PATH

Quick start

1. Create a sandbox

openshell sandbox create --keep --name my-sandbox

--keep prevents the sandbox from being cleaned up when the shell exits so VSCode can reconnect to it later.

2. Generate an SSH config entry

openshell sandbox ssh-config my-sandbox >> ~/.ssh/config

This will append a block like:

Host openshell-my-sandbox
    User sandbox
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    GlobalKnownHostsFile /dev/null
    LogLevel ERROR
    ProxyCommand openshell ssh-proxy --gateway <gateway-name> --name my-sandbox

3. Open VSCode

Open VSCode and run Remote-SSH: Connect to Host... from the command palette (Cmd+Shift+P / Ctrl+Shift+P). Select openshell-my-sandbox from the list. VSCode will open a remote window connected to the sandbox.

Alternatively, from the terminal:

code --remote ssh-remote+openshell-my-sandbox /sandbox

4. Clean up

When you are done, delete the sandbox:

openshell sandbox delete my-sandbox

This also removes any active port forwards.