> ## Documentation Index
> Fetch the complete documentation index at: https://hoopdev-update-to-meta-tags.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Secure Shell (SSH)

> Proxy an SSH Server to remote hosts in your private network.

## Prerequisites

To get the most out of this guide, you will need to:

* Either [create an account in our managed instance](https://use.hoop.dev) or [deploy your own hoop.dev instance](/getting-started/installation/overview)
* You must be your account administrator to perform the following commands

## Features

The table below outlines the features available for this type of connection.

* **Native** - This refers to when a database client connects through a specific protocol, such as an IDE or client libraries through `hoop connect <connection-name>`.
* **One Off -** This term refers to accessing this connection from Hoop Web App.

| Feature                    | Native                | One Off               | Description                                                                  |
| -------------------------- | --------------------- | --------------------- | ---------------------------------------------------------------------------- |
| Audit                      | <Icon icon="xmark" /> | <Icon icon="xmark" /> | The gateway store and audit the commands being issued by the SSH client.     |
| Data Masking (Google DLP)  | <Icon icon="xmark" /> | <Icon icon="xmark" /> | A policy can be enabled to mask sensitive fields dynamically for the output. |
| Data Masking (MS Presidio) | <Icon icon="xmark" /> | <Icon icon="xmark" /> | A policy can be enabled to mask sensitive fields dynamically for the output. |
| Credentials Offload        | <Icon icon="check" /> | <Icon icon="xmark" /> | The user authenticates via SSO instead of using SSH credentials.             |

## Configuration

| Name                     | Type    | Required | Description                                                                                           |
| ------------------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------- |
| HOST                     | env-var | yes      | The IP or hostname of the SSH server                                                                  |
| PORT                     | env-var | no       | The port of the SSH server, default to `22`                                                           |
| USER                     | env-var | yes      | The username of the Linux server                                                                      |
| PASS                     | env-var | no       | The credentials of the username if password authentication is enabled in the SSH server.              |
| AUTHORIZED\_SERVER\_KEYS | env-var | no       | The private key of the user that corresponds to the public key at `$HOME/<user>/.ssh/authorized_keys` |

## Connection Setup

```sh
# ssh server must enable password based authentication
hoop admin create conn myremote-server -a <agent> --overwrite \
    --type application/ssh \
    -e HOST=10.20.30.40 \
    -e USER=root \
    -e PASS=myrootpasswd

# ssh server must enable public key authentication
hoop admin create conn myremote-server -a <agent> --overwrite \
    --type application/ssh \
    -e HOST=10.20.30.40 \
    -e USER=root \
    -e AUTHORIZED_SERVER_KEYS=file:///path/to/your/private/key
```

<Info>
  In upcoming releases, we plan to automate the management of users, keys, and passwords on the remote server.
  Additionally, our roadmap includes adding a UI for managing such type of connections.
</Info>

## How to Use it

To connect automatically, it will listen to a random port and use your local `ssh` client to connect it.

```bash
hoop connect myremote-server
```

In the listen mode, it will listen for connections on the specified port when using the `--port` flag.

```bash
hoop connect myremote-server --port 2222
```

Connect with your local SSH client using another terminal window:

```bash
ssh -p 2222 localhost
```

## SSH Hosts Key

To prevent fingerprint issues when connecting with the local SSH client server,
add the client host key environment variable during gateway setup.

The key must be in `PKCS#8` format and encoded as base64. You can generate a key with `openssl` utility:

```bash
openssl genpkey -algorithm RSA -out ssh_host_hoop_key.pem \
  -pkeyopt rsa_keygen_bits:4096
base64 -i ssh_host_hoop_key.pem
```

* `SSH_CLIENT_HOST_KEY=<base64-encoded-key>`

<Tip>
  To troubleshoot the SSH connection with hosts keys, use the `--debug` flag when running the `hoop connect` command.
  This will provide detailed information about the connection process, including any issues related to parsing the host key.
</Tip>

For more details, refer to the [environment variables documentation](/setup/configuration/env-vars).

## Known Issues

### Warp Terminal

When using Warp Terminal, you might encounter issues due to its unique handling of SSH connections.
To disable it, set this option in your bash profile or your current shell session

```sh
export WARP_USE_SSH_WRAPPER=0
```
