> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SSH

> Let an AI agent run commands on an SSH server without holding its password or key.

An SSH service lets an agent reach an SSH server during a [session](https://infisical.com/docs/documentation/platform/agent-vault/sessions), with clients such as `ssh`. The agent never holds the password or key: the [proxy](https://infisical.com/docs/documentation/platform/agent-vault/proxies) logs in to the server with the service's account. The agent reaches the service through [`infisical agent-vault connect`](https://infisical.com/docs/cli/reference#agent-vault-connect).

## Prerequisites

* The [Admin role](https://infisical.com/docs/documentation/platform/agent-vault/access-control#product-membership) in your Agent Vault project
* An [access bundle](https://infisical.com/docs/documentation/platform/agent-vault/access-bundles.md) to add the service to
* A running [proxy](https://infisical.com/docs/documentation/platform/agent-vault/proxies#create-a-proxy-and-start-it) that can reach the server, and whose HTTP port the agent can reach
* An account on the server with only the access your agents need

## Add an SSH server

**Step 1**

In your Agent Vault project, go to **Access Bundles**. Select your access bundle, then select **Add Service**. In the **Services** list, select **Create New Service**.

**Step 2**

On the **Choose a template** panel, select the **Databases and More** tab, then select **SSH**.

**Step 3**

On the **Details** step, enter a **Name** and the [server's details](#server-details). Select **Continue**.

**Step 4**

On the **Credential** step, set up the [account](#credentials) the proxy logs in as. Select **Continue**.

**Step 5**

Optionally, on the **Hook** step, pick the [hook](https://infisical.com/docs/documentation/platform/agent-vault/hooks.md#attach-a-hook-to-a-service) that checks each connection to this service. Select **Continue**.

**Step 6**

On the **Review** step, select **Add Service**.

Next, [connect your agent](https://infisical.com/docs/documentation/platform/agent-vault/databases-and-ssh#connect-your-agent) to the service.

## Server details

* **Name:** The name the agent connects with, as in `infisical agent-vault connect bastion` (lowercase letters, numbers, and hyphens, at most 63 characters)
* **Host:** The server's host name or IP address, as the proxy reaches it (no scheme, port, path, or variable)
* **Port:** The server's port (defaults to `22`)

## Credentials

### Username and password

Enter the account's **Username** and **Password**. To give each member their own account, leave the username, the password, or both to each member, as described in [member-provided values](https://infisical.com/docs/documentation/platform/agent-vault/http-apis.md#member-provided-values). To use a password that several services share, type `{{` in **Password** and select a [variable](https://infisical.com/docs/documentation/platform/agent-vault/variables).

### SSH key

An SSH service can log in with a key instead of a password. Under **Credential Type**, select **SSH Key**, then enter the **Username**, paste the **Private Key**, and optionally paste an SSH certificate for the key in **Certificate (optional)**.

* The key must not have a passphrase
* Members can't each provide their own key or username
* The key can't use a variable

If the proxy can't use the key, such as a key with a passphrase or a certificate that doesn't match the key, `infisical agent-vault connect` [refuses the service](https://infisical.com/docs/documentation/platform/agent-vault/databases-and-ssh#services-the-proxy-refuses) and says why.

## Limitations

* **SSH port forwarding isn't controlled:** An agent can forward ports through an SSH service to anything the SSH server reaches, and the forwarded traffic isn't recorded, so set `AllowTcpForwarding no` and `PermitTunnel no` for the service's account on the SSH server
* **SSH host keys aren't checked:** The proxy accepts the SSH server's host key without checking it, so run the proxy on a network you trust to reach the server
* **SSH errors aren't shown:** The agent doesn't see what a command writes to standard error, and the session log doesn't record it or the command's exit code
* **Password logins only use SSH's password method:** An SSH server that only allows keyboard-interactive logins rejects a password, so use an [SSH key](#ssh-key) instead

## Troubleshooting

> [accordion] The client says the server closed the connection
>
> The proxy couldn't log in to the server. Check that:
>
> * The service's **Host** and **Port** are reachable from the proxy's machine
> * The account's username and password, or key, are correct
>
> The session's log shows the failed connection as an **Error** row with the reason, and so does the proxy's own log.
>
> If `connect` printed a message about the service's hook, the hook server refused the connection or didn't give a usable answer. See the [hook troubleshooting](https://infisical.com/docs/documentation/platform/agent-vault/hooks.md#troubleshooting).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.