# Chalk CLI Reference: Tunnels
source: https://docs.chalk.ai/cli#tunnels

Reach a service running inside a container from your machine, including ssh over [`chalk session proxy`](https://docs.chalk.ai/docs/tunnels).

## `chalk session proxy`
source: https://docs.chalk.ai/cli?command=session_proxy

```bash
chalk session proxy <container>
```

Use the 'chalk session proxy' command to connect a port inside a container to this process's stdin and stdout, so a local client can speak to a server running in the container.

It is built for ssh's ProxyCommand: nothing but the proxied bytes is written to stdout, the connection carries no PTY, and the process inside the container is killed when the local side goes away, so a connection leaves nothing behind.

The container must be host-backed ('chalk container run --compute-class host'), must be running an sshd, and must have socat, nc, or bash for the connection itself.

Put a block like the ones in the examples below in ~/.ssh/config, and ssh, scp, rsync, port forwarding, and remote IDEs all work against the container.

**Flags**

- `--container-name <name>` (string)
  Container name to use when the name would otherwise be interpreted as a container ID.
- `-p, --port <port>` (int, default `22`)
  Port inside the container to connect to.
- `--target-host <host>` (string, default `127.0.0.1`)
  Address inside the container's network namespace to connect to.

**Example**

```
# ~/.ssh/config, for one container, named by ID or by name:
#
#   Host my-container
#     User root
#     ProxyCommand chalk session proxy --dir /path/to/project %h
#
# Or for every container at once, as chalk-sbx-<container id or name>. The
# prefix is what keeps the pattern from matching real hosts, so it has to be
# stripped back off before the name reaches this command:
#
#   Host chalk-sbx-*
#     User root
#     ProxyCommand sh -c 'exec chalk session proxy --dir /path/to/project "${0#chalk-sbx-}"' %n
#
# Or run the proxy directly:
$ chalk session proxy 550e8400-e29b-41d4-a716-446655440000
$ chalk session proxy my-container --port 2222
```

## `chalk sandbox configure_ssh`
source: https://docs.chalk.ai/cli?command=sandbox_configure_ssh

```bash
chalk sandbox configure-ssh
```

Use the 'chalk sandbox configure-ssh' command to teach ssh how to reach sandboxes in your Chalk environment.

It writes one block to ~/.ssh/config that routes any host named with the 'chalk-sbx-' prefix through 'chalk session proxy', so 'ssh chalk-sbx-my-sandbox' opens a shell in that sandbox, and scp, rsync, port forwarding, and remote IDEs work against it too.

The block is delimited by markers and rewritten in place on every run, so it is safe to re-run after moving the chalk binary or switching projects. It is placed at the top of the file, because ssh takes the first value it finds for each option and a catch-all 'Host *' block later in the file would otherwise win.

The sandbox itself has to be reachable: create it with '--compute-class host', and use an image that already runs an sshd and contains socat, nc, or bash. Sandboxes have no outbound internet, so none of that can be installed at runtime.

**Flags**

- `--dry-run <dry-run>` (bool, default `false`)
  Print the ssh config block instead of writing it.
- `--prefix <prefix>` (string, default `chalk-sbx-`)
  Host alias prefix. 'ssh ' reaches a sandbox.
- `--user <user>` (string, default `root`)
  User to log in as inside the sandbox.
- `--port <port>` (int, default `22`)
  Port the sandbox's sshd listens on.
- `--ssh-config <path>` (string)
  Path to the ssh config file to write.

**Example**

```
# See what would be written, without touching anything
$ chalk sandbox configure-ssh --dry-run

# Write it
$ chalk sandbox configure-ssh

# Then, for a sandbox named 'my-sandbox' or by its ID
$ ssh chalk-sbx-my-sandbox
$ scp ./file.py chalk-sbx-my-sandbox:/tmp/

# Use a different alias prefix, login user, or sshd port
$ chalk sandbox configure-ssh --prefix sbx- --user dev --port 2222
```
