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

# vastai attach ssh

Attach an ssh key to an instance. This will allow you to connect to the instance with the ssh key

## Usage

```bash theme={null}
vastai attach ssh instance_id ssh_key
```

## Arguments

<ParamField path="instance_id" type="integer" required>
  id of instance to attach to
</ParamField>

<ParamField path="ssh_key" type="string" required>
  ssh key to attach to instance
</ParamField>

## Description

Attach an ssh key to an instance. This will allow you to connect to the instance with the ssh key.

## Examples

```bash theme={null}
vast attach ssh 12371 AAAAB3NzaC1yc2EAAA...
 vast attach ssh 12371 $(cat ~/.ssh/id_rsa.pub)
 vast attach ssh 12371 ~/.ssh/id_rsa.pub

All examples attaches the ssh key to instance 12371
```

## Global Options

The following options are available for all commands:

| Option          | Description                                           |
| --------------- | ----------------------------------------------------- |
| `--url URL`     | Server REST API URL                                   |
| `--retry N`     | Retry limit                                           |
| `--raw`         | Output machine-readable JSON                          |
| `--explain`     | Verbose explanation of API calls                      |
| `--api-key KEY` | API key (defaults to `~/.config/vastai/vast_api_key`) |
