---
title: "attach ssh-key"
method: POST
path: "/api/v0/instances/{id}/ssh/"
tags: ["Instances"]
---

# attach ssh-key

`POST /api/v0/instances/{id}/ssh/`

Attaches an SSH key to the specified instance, allowing SSH access using the provided key.

CLI Usage: `vastai attach ssh <instance_id> <ssh_key>`

## Path parameters

- `id` integer, required

## Request body

- object
  - `ssh_key` string — The SSH key to attach to the instance

## Response `200`

SSH key attached successfully

- object
  - `success` boolean
  - `msg` string

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found

---

[API](https://skmtc.net/vast/apis/vast-ai-api.md) · [All operations](https://skmtc.net/vast/apis/vast-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/vast/vast-ai-api/revisions/4ed14f79f796/schema)
