---
title: CLI Tunneling
---

<p class="note">Note: Applies to CLI v2.</p>

CLI supports tunneling all of its traffic (HTTP and SSH) through a SOCKS 5 proxy specified via `BOSH_ALL_PROXY` environment variable. (Custom environment variable was chosen instead of using `all_proxy` environment variable to avoid accidently tunneling non-CLI traffic.)

Common use cases for tunneling through a jumpbox VM include:

- deploying Director VM with `bosh create-env` command
- accessing the Director and UAA APIs

<pre class="terminal">
# set a tunnel
# -D : local SOCKS port
# -f : forks the process in the background
# -C : compresses data before sending
# -N : tells SSH that no command will be sent once the tunnel is up
$ ssh -D 5000 -fNC jumpbox@jumpbox-ip -i jumpbox.key

# let CLI know via environment variable
$ export BOSH_ALL_PROXY=socks5://localhost:5000

$ bosh create-env bosh-deployment/bosh.yml ...
$ bosh alias-env aws -e director-ip --ca-cert ...
</pre>

---
title: CLI Tunneling
---

<p class="note">Note: Applies to CLI v2.</p>

CLI supports tunneling all of its traffic (HTTP and SSH) through a SOCKS 5 proxy specified via `BOSH_ALL_PROXY` environment variable. (Custom environment variable was chosen instead of using `all_proxy` environment variable to avoid accidently tunneling non-CLI traffic.)

Common use cases for tunneling through a jumpbox VM include:

- deploying Director VM with `bosh create-env` command
- accessing the Director and UAA APIs

<pre class="terminal">
# set a tunnel
# -D : local SOCKS port
# -f : forks the process in the background
# -C : compresses data before sending
# -N : tells SSH that no command will be sent once the tunnel is up
# -4 : force SSH to use IPv4 to avoid the dreaded `bind: Cannot assign requested address` error
$ ssh -4 -D 5000 -fNC jumpbox@jumpbox-ip -i jumpbox.key

# let CLI know via environment variable
$ export BOSH_ALL_PROXY=socks5://localhost:5000

$ bosh create-env bosh-deployment/bosh.yml ...
$ bosh alias-env aws -e director-ip --ca-cert ...
</pre>

Add -4 option to fix IPv6 problems
Add -4 option to fix IPv6 problems

Added the `-4` option to the SSH command to avoid the `bind: Cannot assign requested address` on modern systems that try to listen on the IPv6 address `::1`