> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/keeperpam/privileged-access-manager/tunnels/ssh-proxy-in-tunnels.md).

# SSH proxy in tunnels

Native SSH clients, zero-credential access — all at once

### Overview

**KeeperSSH Proxy** lets you point your own SSH client (OpenSSH, MobaXterm, and so on) at a Keeper tunnel and get a working session on the target without ever knowing the target's credentials. The Gateway acts as a transparent SSH proxy: your client logs in to a local port, and the Gateway signs in to the real target with the credentials stored in your Keeper vault, then relays the session between the two.

Unlike a plain tunnel, which only forwards raw bytes and expects the client to authenticate to the target itself, a proxied tunnel keeps the real password or private key inside Keeper. Whatever username or password your client sends is accepted and discarded; the vault credential is used on the upstream leg. Shell, `exec`, SFTP/SCP, local port forwarding (`-L`) and X11 forwarding all work through the proxy as they would on a direct SSH connection.

### Prerequisites

The proxy builds on a regular tunnel, so the SSH record must already be created and configured for connections and tunneling. This covers the PAM Machine record with the `ssh` protocol, its launch credentials, the PAM Configuration, and enabling tunneling on the record. All of that is explained on the parent page, [Tunnels](https://docs.keeper.io/keeperpam/privileged-access-manager/tunnels.md).

In addition, the proxy needs these versions:

| Component        | Minimum version | Notes                                                                                                                                                      |
| ---------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Keeper Gateway   | **1.9.0.59**    | It provides KeeperSSH Proxy, including X11 forwarding. Upgrading the Gateway is all that is needed on the server side.                                     |
| Keeper Commander | **18.1.8**      | Adds the options used to target the new proxied RDP/SSH tunnels, for example `pam tunnel edit --keeper-proxy=on`. Only needed if you use Keeper Commander. |

The record must have **launch credentials** (a linked PAM User) or ephemeral (JIT) credentials configured. These are what the Gateway injects when it signs in to the target.

### Setting up the proxied tunnel

You can enable and start the proxied tunnel either from Keeper Commander or from the Keeper GUI clients.

#### Option 1: Keeper Commander

Enable the proxy on the record. Keeper Commander reads the record's connection protocol (`ssh`) and selects KeeperSSH Proxy automatically:

```
My Vault> pam tunnel edit --keeper-proxy=on <SSH_RECORD_UID>
```

If the record has no launch credentials (and no ephemeral JIT), the command stops and tells you to assign one first with `pam connection edit <SSH_RECORD_UID> --launch-user <PAM_USER_RECORD>`. To turn the proxy off again use `--keeper-proxy=off`; use `--keeper-proxy=default` to remove the setting from the record, which returns it to a plain tunnel.

Then start the tunnel as usual:

```
My Vault> pam tunnel start <SSH_RECORD_UID>

KeeperSSH Proxy ready
  Listening:  127.0.0.1:49152
  Connect:    ssh -p 49152 <any>@127.0.0.1
  Note:       when your SSH client prompts for credentials supply any value. The proxy substitutes the credentials configured in your Keeper vault before forwarding to the target.
Connection established successfully.
Record: server-ssh-with-pwd-1-proxy
Remote: 127.0.0.1:222
Local: 127.0.0.1:49152
Conversation ID: On955tK3WDYs6f63au3nqA
```

Keeper Commander detects the proxy from the record's own setting, so adding `--proxy` to `pam tunnel start` is optional. The **Listening** line is the one that matters: the local port is `49152` when that port is free, and a different free port otherwise. Always copy the port from the output, or pin it yourself with `--port <PORT>` (the start fails if that port is taken).

If the record lets users choose their own credentials (**Allow users to select credentials from their vault**), you can use a different PAM User record for a single session:

```
My Vault> pam tunnel start <SSH_RECORD_UID> --credential <PAM_USER_RECORD_UID_OR_TITLE>
```

When you are finished, stop the tunnels:

```
My Vault> pam tunnel stop --all
```

<figure><img src="https://762006384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJXOXEifAmpyvNVL1to%2Fuploads%2F6uMn7muXpqRUcpAYF9QD%2FKC_tunnel_ssh.jpg?alt=media&amp;token=6fa61db2-cb22-4e59-97c2-c1b1c952d057" alt=""><figcaption><p>Keeper Commander shell starting SSH proxied tunnel</p></figcaption></figure>

#### Option 2: Web Vault or Keeper Desktop App

Both the Web Vault and the Desktop App can enable the proxy on a record, but a tunnel opens a port on your own machine, so **starting** it is done in the **Keeper Desktop App**.

* **Enable the proxy.** Open the SSH record, choose **Edit**, go to **PAM Settings**, and in the **Tunnel** section make sure **Enable Tunnel** is ticked. Under **SSH Proxy**, tick **Enable SSH Proxy** and save the record. The SSH Proxy section is shown only for records whose connection protocol is SSH.
*

```
<figure><img src="../../.gitbook/assets/ssh_proxy_tunnel_settings.jpg" alt=""><figcaption><p><strong>Enable the proxy in web vault.</strong> <strong>Edit</strong> > <strong>PAM Settings</strong> > <strong>Tunnel</strong> > <strong>Enable Tunnel</strong> and <strong>Enable SSH Proxy</strong>.</p></figcaption></figure>
```

* **Start the tunnel.** In the Desktop App, open the record (or find it in the tunnels list) and click **Start Tunnel**. Depending on the record, the button either starts immediately with the record's launch credential, or opens a menu to pick one of your own credentials (when users may select credentials from their vault). The tunnel row shows the local port to connect to; use it as the `-p` value in your SSH client.
*

```
<figure><img src="../../.gitbook/assets/ssh_proxed_tunnel_start_gui.jpg" alt=""><figcaption><p><strong>Starting the tunnel</strong> in the Desktop App</p></figcaption></figure>
```

If the Gateway is older than the required version, the Desktop App refuses to start the tunnel and shows "SSH Proxy requires gateway version ... or higher. Please update your gateway."

### Connecting with an SSH client

With the tunnel running, connect to the local port with any SSH client:

```
ssh -p 49152 anyuser@127.0.0.1
```

The username can be anything and the password prompt accepts any value, because the proxy replaces both with the vault credential. If the record uses a private key, the proxy handles that on the upstream leg as well; your client does not need a key.

#### Host key prompts

Every time a proxied tunnel starts, the Gateway creates a fresh host key for the local listener. Your SSH client will therefore ask you to trust the key on first connect, and will warn about a changed key when you reuse the same `127.0.0.1:<port>` later. This is expected, and the warning is about the local proxy, not the target. For a tunnel that only listens on loopback you can skip the prompt:

```
:: Windows
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=NUL -p 49152 anyuser@127.0.0.1

# Linux / macOS
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 49152 anyuser@127.0.0.1
```

SSH session on Windows:

<figure><img src="https://762006384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJXOXEifAmpyvNVL1to%2Fuploads%2FVY5vcvN3JmZYol3uB9nT%2Fcmd_ssh_proxy.jpg?alt=media&amp;token=cb6c8b20-05fc-4a23-bb5e-ac1cd8b6f468" alt=""><figcaption><p>SSH session on Windows</p></figcaption></figure>

#### What works through the proxy

| Feature                               | Supported | Notes                                               |
| ------------------------------------- | --------- | --------------------------------------------------- |
| Interactive shell, `ssh host command` | Yes       |                                                     |
| SFTP and SCP                          | Yes       | Including the SFTP browser in MobaXterm.            |
| Local port forwarding (`-L`)          | Yes       | Reaches hosts that are reachable from the target.   |
| X11 forwarding (`-X` / `-Y`)          | Yes       | Transparent; see [X11 forwarding](#x11-forwarding). |
| Password or private key on the target | Yes       | Injected from the vault; the client never sees it.  |
| Agent forwarding (`-A`)               | No        | Refused by design.                                  |
| Remote port forwarding (`-R`)         | No        | Refused by design.                                  |

### X11 forwarding

X11 forwarding through a proxied tunnel is **transparent**: the only thing the client has to do is enable the proxy on the record. There is no extra record setting, Keeper Commander flag or Gateway option for X11. The proxy passes the SSH client's X11 request to the target and relays the connections the target opens back to your X server, so remote graphical programs appear on your desktop. This works from the Gateway version listed under [Prerequisites](#prerequisites).

You need an X server on your workstation, and the SSH client must ask for forwarding (`-X` or `-Y`).

#### Windows 11

On Windows, use any X server; the example below uses VcXsrv. Keeper Commander is running on the same Windows machine.

1. Enable the proxy and start the tunnel from Keeper Commander (or from the Desktop App, see above):

   ```
   My Vault> pam tunnel edit --keeper-proxy=on <SSH_RECORD_UID>
   My Vault> pam tunnel start <SSH_RECORD_UID>
   ```
2. In a Windows command prompt, point `DISPLAY` at the local X server and start it:

   ```
   C:\> set DISPLAY=localhost:0.0
   C:\> D:\PROGRAMS\XServer\vcxsrv\vcxsrv.exe :0 -multiwindow -clipboard -ac
   ```
3. Run an X11 program on the target over the proxied SSH tunnel:

   ```
   C:\> ssh -Y user@127.0.0.1 -p 49152 xcalc
   ```

The last command starts `xcalc` on the target using X11 forwarding over the proxied SSH tunnel, and its window opens on your Windows desktop. You can replace `user` with any name you like, because the proxy ignores it. The one value you must get right is `-p <PORT>`: copy it from the `Listening` line of the `pam tunnel start` output. The default is `49152` if that port is unused.

* The Windows OpenSSH client has no `xauth`, so it prints `No xauth data;` That is why the X server is started with `-ac` (access control off).
* A warning such as `Cannot convert string "calculator" to type Pixmap` comes from missing fonts and icons in `xcalc` and can be ignored.

<figure><img src="https://762006384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJXOXEifAmpyvNVL1to%2Fuploads%2FxgeZUUjbtEZVdy3PSbyR%2Fcmd_ssh_proxy_x11_xcalc.jpg?alt=media&amp;token=38e494be-38c3-4535-af22-cf791e2e1a1d" alt=""><figcaption><p>SSH session with X11 forwarding on Windows running xclac</p></figcaption></figure>

**MobaXterm.** MobaXterm has a built-in X server, so you do not need VcXsrv. Create an SSH session with *Remote host* `127.0.0.1`, *Port* set to the proxied port, any *Username*, and **X11-Forwarding** ticked. Optionally set *Execute command* to `xcalc`. When MobaXterm prompts for a password, enter anything.

MobaXterm SSH setup (with X11 forwarding)

<figure><img src="https://762006384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJXOXEifAmpyvNVL1to%2Fuploads%2FAOyBQjp2iGe9yIZFrIId%2Fmoba_xterm_ssh_proxy_x11_setup.jpg?alt=media&amp;token=272adc76-e8f2-4d6f-99b0-283821bec05b" alt=""><figcaption><p>MobaXterm SSH setup (xcalc with X11 forwarding)</p></figcaption></figure>

MobaXterm SSH session running **`xcalc`**

<figure><img src="https://762006384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJXOXEifAmpyvNVL1to%2Fuploads%2Fjt4boU92Z0ODrOCBL74Y%2Fmoba_xterm_ssh_proxy_x11_xcalc.jpg?alt=media&amp;token=e92d42f0-f89b-48c9-b63e-4005b9a5c1a8" alt=""><figcaption><p>MobaXterm SSH session running <strong><code>xcalc</code></strong></p></figcaption></figure>

#### Linux

On a Linux desktop, an X server is normally already running (including XWayland on Wayland desktops), so you only need to start the tunnel and connect. Keeper Commander is running on the same Linux machine.

```
My Vault> pam tunnel edit --keeper-proxy=on <SSH_RECORD_UID>
My Vault> pam tunnel start <SSH_RECORD_UID>
```

In a second terminal of your desktop session, check that `DISPLAY` is set (it is usually `:0` or `:1`) and connect:

```
$ echo $DISPLAY
:0
$ ssh -Y user@127.0.0.1 -p 49152 xcalc
```

As on Windows, `user` can be anything and `-p <PORT>` must match the port shown by `pam tunnel start`. You can use `-X` (untrusted forwarding) instead of `-Y`, but some programs refuse to run that way. If the program does not appear, make sure you are in a graphical session and not a plain SSH login (where `DISPLAY` would be empty).

### Troubleshooting

| Symptom                                                                                 | Likely cause and fix                                                                                                                                                                                             |
| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `No Launch Credentials assigned to record`                                              | The record has no linked PAM User. Add one with `pam connection edit <SSH_RECORD_UID> --launch-user <PAM_USER_RECORD>` and run `pam tunnel edit --keeper-proxy=on` again.                                        |
| `--keeper-proxy has no effect for record ...`                                           | The record's connection protocol is not `ssh`, `rdp` or a database protocol. Set the protocol on the record first.                                                                                               |
| `--credential requires the "Allow users to select credentials from their vault" option` | Enable that option on the record, then retry.                                                                                                                                                                    |
| `SSH Proxy requires gateway version ... or higher` (Desktop App)                        | Update the Gateway, see [Prerequisites](#prerequisites).                                                                                                                                                         |
| `ssh: connect to host 127.0.0.1 port 49152: Connection refused`                         | The tunnel is not running, or it picked a different port. Check the `Listening` line of `pam tunnel start`, the port shown in the Desktop App, or run `pam tunnel list`.                                         |
| `REMOTE HOST IDENTIFICATION HAS CHANGED`                                                | Expected after each new tunnel start, see Host key prompts.                                                                                                                                                      |
| X11 program does not open                                                               | Make sure the X server is running and `DISPLAY` is set in the shell that runs `ssh`, that you passed `-X` or `-Y`, and that the target has the program installed (and `X11Forwarding yes` in its `sshd_config`). |

### See also

* `pam tunnel edit --help` and `pam tunnel start --help` in [Keeper Commander](https://docs.keeper.io/keeperpam/commander-cli/command-reference/keeperpam-commands.md#sub-command-tunnel) for the full option list.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.keeper.io/keeperpam/privileged-access-manager/tunnels/ssh-proxy-in-tunnels.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
