11---
2- title : " Expose SSH"
2+ title : " SSH"
33description : " How to open secure SSH access into a sandbox for interactive debugging, editor sessions, or long-running processes."
44---
55
66Sandboxes can hand out SSH credentials so you can inspect the filesystem, tail
7- logs, run editors, or forward ports while the microVM stays isolated on the
8- Deploy edge .
7+ logs, run editors, or forward ports. SSH access is available both in your
8+ terminal as a command and in the Deno Deploy Sandbox UI .
99
1010``` tsx
1111import { Sandbox } from " @deno/sandbox" ;
@@ -24,18 +24,10 @@ script releases its references (for example, the `await using` block ends) the
2424sandbox shuts down and the SSH endpoint disappears; you can also call
2525` sandbox.kill() ` if you need to tear it down immediately.
2626
27- ## When to use SSH access
28-
29- - Debugging agent-generated code that only fails in the sandbox
30- - Editing files with a full-screen terminal editor or remote VS Code
31- - Streaming logs in real time without instrumenting application code
32- - Running profiling or inspection tools that are easier to use manually
33-
34- Because each sandbox is already isolated, opening SSH does not compromise other
35- projects or organizations.
36-
3727## Connecting from your machine
3828
29+ ### exposeSsh method
30+
39311 . Request credentials via ` sandbox.exposeSsh() ` .
40322 . Connect using the provided username and hostname:
4133
@@ -46,13 +38,34 @@ ssh ${username}@${hostname}
46383 . Use regular terminal workflows: copy files, run top, tail logs, or attach to
4739 running processes.
4840
49- ::: tip
41+ ## In the terminal
42+
43+ You can SSH into your sandbox from the terminal using the ` --ssh ` flag when
44+ running your script:
45+
46+ ``` bash
47+ deno sandbox create -ssh
48+ ```
49+
50+ ## In the Deno Deploy console
51+
52+ After creating a sandbox, you can SSH into it in the Deno Deploy web app.
5053
51- Tip: combine SSH with
52- [ port forwarding] ( https://man.openbsd.org/ssh#LOCAL_FORWARDING ) to view dev
53- servers that are bound to ` localhost ` inside the sandbox.
54+ 1 . Log in to [ console.deno.com] ( https://console.deno.com/ ) and navigate to the
55+ "Sandboxes" section.
56+ 2 . Either create a new sandbox or select an existing one from the list.
57+ 3 . Click ** Start SSH terminal** to open an interactive terminal session in your
58+ browser.
5459
55- :::
60+ ## When to use SSH access
61+
62+ - Debugging agent-generated code that only fails in the sandbox
63+ - Editing files with a full-screen terminal editor or remote VS Code
64+ - Streaming logs in real time without instrumenting application code
65+ - Running profiling or inspection tools that are easier to use manually
66+
67+ Because each sandbox is already isolated, opening SSH does not compromise other
68+ projects or organizations.
5669
5770## Security considerations
5871
0 commit comments