Skip to content

Commit 73b2f53

Browse files
committed
[Containers] Document shells without SSH keys
wrangler containers ssh opens a shell in Containers that use the durable_object scheduling policy without authorized_keys or OpenSSH. OpenSSH through a Wrangler ProxyCommand stays the way to reach the default policy and jurisdictions, and to use port forwarding and SFTP.
1 parent 4f88497 commit 73b2f53

5 files changed

Lines changed: 102 additions & 40 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Open a shell in a container without SSH keys
3+
description: wrangler containers ssh no longer needs authorized_keys or a local OpenSSH install for Containers that use the durable_object scheduling policy.
4+
products:
5+
- containers
6+
date: 2026-12-01
7+
---
8+
9+
[`wrangler containers ssh`](/workers/wrangler/commands/containers/#containers-ssh) now opens a shell in a running Container without SSH keys. You no longer need to add a public key to `authorized_keys` or install OpenSSH locally. This works for Containers that use the [`durable_object` scheduling policy](/containers/configuration/scheduling-policy/).
10+
11+
```sh
12+
wrangler containers ssh <INSTANCE_ID>
13+
```
14+
15+
To run a command, pass it after `--`. Wrangler allocates a terminal when its standard input and standard output are terminals. It exits with the exit code of the remote command.
16+
17+
```sh
18+
wrangler containers ssh <INSTANCE_ID> -- ls /
19+
```
20+
21+
Port forwarding, SFTP, Containers in a jurisdiction, and Containers that use the `default` scheduling policy still need an [OpenSSH connection](/containers/guides/ssh/#connect-with-openssh) with Wrangler as the `ProxyCommand`.
22+
23+
For more information, refer to [SSH](/containers/guides/ssh/).

‎src/content/docs/containers/configuration/scheduling-policy.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Container instances that use the `durable_object` policy do not participate in a
200200

201201
### Configure SSH
202202

203-
The `durable_object` policy supports the `ssh` and `authorized_keys` fields. Refer to [SSH](/containers/guides/ssh/).
203+
You can open a shell in instances that use the `durable_object` policy with `wrangler containers ssh`, without SSH keys. Instances in a jurisdiction need SSH keys. The policy also supports the `ssh` and `authorized_keys` fields. Refer to [SSH](/containers/guides/ssh/).
204204

205205
## Related resources
206206

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: SSH
4-
description: Connect to running container instances with SSH.
4+
description: Open a shell in running container instances with Wrangler.
55
sidebar:
66
order: 5
77
products:
@@ -10,19 +10,74 @@ products:
1010

1111
import { WranglerConfig } from "~/components";
1212

13-
Anyone with write access to a Container can SSH into it with Wrangler as long as a matching public key is listed in `authorized_keys`.
13+
Anyone with write access to a Container can open a shell in it with [`wrangler containers ssh`](/workers/wrangler/commands/containers/#containers-ssh).
1414

15-
SSH does not expose a publicly accessible port on the Container. The only way to connect is through Wrangler with [`wrangler containers ssh`](/workers/wrangler/commands/containers/#containers-ssh), which authenticates against your Cloudflare account.
15+
Containers do not expose a public port for the shell or SSH. The only way to connect is through Wrangler, which authenticates against your Cloudflare account.
1616

17-
## Configure SSH
17+
## Open a shell
1818

19-
SSH can be configured in your [Container's configuration](/workers/wrangler/configuration/#containers) with the `ssh` and `authorized_keys` properties. Only the `ssh-ed25519` key type is supported.
19+
Containers that use the [`durable_object` scheduling policy](/containers/configuration/scheduling-policy/) do not need SSH keys or a local OpenSSH install. For Containers in a [jurisdiction](/containers/concepts/placement/) and for other Containers, refer to [Connect with OpenSSH](#connect-with-openssh).
2020

21-
The `ssh.enabled` property only controls whether you can SSH into a Container through Wrangler. It defaults to `true`. Set it to `false` to disable SSH access completely.
21+
Find the instance ID for your Container by running [`wrangler containers instances`](/workers/wrangler/commands/containers/#containers-instances) or in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/containers).
22+
The instance must be running.
23+
Wrangler does not start a stopped Container.
24+
An open shell does not keep a Container alive.
25+
26+
To open the default shell, run:
27+
28+
```sh
29+
wrangler containers ssh <INSTANCE_ID>
30+
```
31+
32+
To run a command instead of the default shell, pass it after `--`:
33+
34+
```sh
35+
wrangler containers ssh <INSTANCE_ID> -- ls -al
36+
```
37+
38+
Wrangler allocates a terminal when its standard input and standard output are terminals. Pass `--tty` to always allocate a terminal, or `--no-tty` to never allocate one. Wrangler exits with the exit code of the remote command.
39+
40+
If standard input and standard output are both redirected and you do not pass a command, Wrangler acts as an [OpenSSH proxy](#connect-with-openssh). To run a shell with redirected streams, pass a command after `--`, or pass `--tty`.
41+
42+
You can pipe data to the command. For example, to copy a file into the Container:
43+
44+
```sh
45+
cat config.json | wrangler containers ssh <INSTANCE_ID> -- sh -c 'cat > /tmp/config.json'
46+
```
47+
48+
## Turn off SSH
49+
50+
The `ssh.enabled` property in your [Container configuration](/workers/wrangler/configuration/#ssh) controls all access through `wrangler containers ssh`. It defaults to `true`. Set it to `false` to turn off shell and SSH access:
51+
52+
<WranglerConfig>
53+
54+
```jsonc
55+
{
56+
"containers": [
57+
{
58+
// other options here...
59+
"ssh": {
60+
"enabled": false
61+
}
62+
}
63+
]
64+
}
65+
```
66+
67+
</WranglerConfig>
68+
69+
## Connect with OpenSSH
70+
71+
To connect with your local OpenSSH client, use `wrangler containers ssh` as an OpenSSH `ProxyCommand`. You need this connection for:
72+
73+
- Containers that use the `default` scheduling policy
74+
- Containers in a jurisdiction
75+
- Port forwarding
76+
- SFTP and other tools that use the SSH protocol, such as VS Code Remote-SSH
2277

23-
## Connect with Wrangler
78+
SFTP also needs an SFTP server in the Container image, such as the `openssh-sftp-server` package on Debian.
2479

25-
To SSH into a Container with Wrangler, add an `ssh-ed25519` public key to `authorized_keys` in your Container configuration. The following example shows a basic configuration:
80+
The OpenSSH connection needs an `ssh-ed25519` public key in `authorized_keys` in your Container configuration. Only the `ssh-ed25519` key type is supported. The following example shows a basic configuration:
2681

2782
<WranglerConfig>
2883

@@ -46,32 +101,18 @@ To SSH into a Container with Wrangler, add an `ssh-ed25519` public key to `autho
46101

47102
For more information on configuring SSH, refer to [SSH configuration](/workers/wrangler/configuration/#ssh).
48103

49-
Find the instance ID for your Container by running [`wrangler containers instances`](/workers/wrangler/commands/containers/#containers-instances) or in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/containers).
50-
The instance you want to SSH into must be running.
51-
SSH will not start a stopped Container, and an active SSH connection alone will not keep a Container alive.
52-
53-
Once SSH is configured and the Container is running, open the SSH connection with:
54-
55-
```bash
56-
wrangler containers ssh <INSTANCE_ID>
57-
```
58-
59-
To run a command instead of the default shell, pass it after `--`. For interactive commands, such as `top`, also pass `--tty` to allocate a terminal:
104+
Once the key is configured and the Container is running, connect with:
60105

61-
```bash
62-
wrangler containers ssh <INSTANCE_ID> --tty -- top
106+
```sh
107+
ssh -o ProxyCommand="wrangler containers ssh %h" cloudchamber@<INSTANCE_ID>
63108
```
64109

65-
## Use as SSH proxy
66-
67-
You can use `wrangler containers ssh` as an OpenSSH `ProxyCommand`. This lets your local SSH client connect through Wrangler.
110+
Wrangler pipes standard input and output to the SSH server in the running Container. You can also pass `--stdio` to force this mode. Add other OpenSSH options as usual. For example, to forward local port `8080` to port `8080` in the Container:
68111

69112
```sh
70-
ssh -o ProxyCommand="wrangler containers ssh %h" cloudchamber@<INSTANCE_ID>
113+
ssh -o ProxyCommand="wrangler containers ssh %h" -L 8080:localhost:8080 cloudchamber@<INSTANCE_ID>
71114
```
72115

73-
When used this way, Wrangler pipes standard input and output to the SSH server in the running Container. You can also pass `--stdio` to force this mode.
74-
75116
## Process visibility
76117

77-
Without the [`containers_pid_namespace`](/workers/configuration/compatibility-flags/#use-an-isolated-pid-namespace-for-containers) compatibility flag, all processes inside the VM are visible when you connect to your Container through SSH. This flag is turned on by default for Workers with a [compatibility date](/workers/configuration/compatibility-dates/) of `2026-04-01` or later.
118+
Without the [`containers_pid_namespace`](/workers/configuration/compatibility-flags/#use-an-isolated-pid-namespace-for-containers) compatibility flag, all processes inside the VM are visible when you connect to your Container. This flag is turned on by default for Workers with a [compatibility date](/workers/configuration/compatibility-dates/) of `2026-04-01` or later.

‎src/content/docs/workers/wrangler/configuration.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,13 +1660,13 @@ Configuration for SSH access to a Container instance through Wrangler. SSH confi
16601660
The following options are available:
16611661

16621662
- `enabled` <Type text="boolean" /> <MetaInfo text="optional" />
1663-
- Whether SSH through Wrangler is enabled. Defaults to `true`. Set to `false` to disable SSH access.
1663+
- Whether `wrangler containers ssh` can connect. Defaults to `true`. Set to `false` to turn off shell and SSH access.
16641664
- `port` <Type text="number" /> <MetaInfo text="optional" />
1665-
- The port for the SSH service to run on. Defaults to `22`.
1665+
- The port for the SSH service to run on. Defaults to `22`. Only [OpenSSH connections](/containers/guides/ssh/#connect-with-openssh) use it.
16661666

16671667
### Authorized keys
16681668

1669-
An authorized key is a public key that can be used to SSH into a Container.
1669+
An authorized key is a public key that can be used to [connect to a Container with OpenSSH](/containers/guides/ssh/#connect-with-openssh). A shell opened with `wrangler containers ssh` does not need one.
16701670

16711671
The following are properties of a key:
16721672

‎src/content/partials/workers/wrangler-commands/containers.mdx‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ wrangler containers push <TAG> [OPTIONS]
243243

244244
<AnchorHeading title="`ssh`" slug="containers-ssh" depth={3} />
245245

246-
Connect to a running Container instance using SSH. Refer to [SSH](/containers/guides/ssh/) for configuration details.
246+
Open a shell in a running Container instance. Refer to [SSH](/containers/guides/ssh/) for configuration details.
247247

248248
```txt
249249
wrangler containers ssh <INSTANCE_ID> [OPTIONS]
@@ -255,13 +255,11 @@ You can also specify a command to run, instead of the default shell. For example
255255
wrangler containers ssh <INSTANCE_ID> -- ls -al
256256
```
257257

258-
Only the default shell gets a terminal automatically. To run an interactive command, such as `top`, pass `--tty`:
259-
260-
```txt
261-
wrangler containers ssh <INSTANCE_ID> --tty -- top
262-
```
258+
Wrangler exits with the exit code of the remote command.
263259

264260
- `INSTANCE_ID` <Type text="string" /> <MetaInfo text="required" />
265-
- The ID of the Container instance to SSH into.
261+
- The ID of the Container instance to connect to.
266262
- `-t, --tty` <Type text="boolean" /> <MetaInfo text="optional" />
267-
- Force pseudo-terminal (PTY) allocation. Use this when running an interactive command.
263+
- Allocate a pseudo-terminal (PTY). By default, Wrangler allocates one when standard input and standard output are terminals. Pass `--no-tty` to never allocate one.
264+
- `--stdio` <Type text="boolean" /> <MetaInfo text="optional" />
265+
- Proxy SSH traffic over standard input and standard output. Use this to run Wrangler as an OpenSSH `ProxyCommand`. Refer to [Connect with OpenSSH](/containers/guides/ssh/#connect-with-openssh).

0 commit comments

Comments
 (0)