> For the complete documentation index, see [llms.txt](https://docs.plenit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plenit.com/docs-en/reference/servers-api/sshkeypair/addsshkeypairtoserver.md).

# Use Cases

* **Enable SSH Access on a Newly Provisioned Server** After creating a server and an SSH key pair separately, call this endpoint to associate the key with the server. This completes the provisioning workflow by enabling secure, password-less SSH authentication from the moment the server is accessible.
* **Deploy the Same SSH Key Across Multiple Servers at Once** The `serverId` field accepts an array of server IDs, so you can attach a single SSH key pair to several servers in one request. Use this to roll out a shared team key or a deployment key across your entire fleet without making repeated API calls.
* **Grant a New Team Member Access to Existing Infrastructure** When a new developer or operator joins the team, create an SSH key pair with their public key and then attach it to all servers they need access to. This provides controlled, auditable access without modifying individual server configurations manually.
* **Automate Key Distribution in CI/CD Pipelines** Integrate this endpoint into your infrastructure automation to programmatically assign SSH keys to servers during deployment. A pipeline can create a key pair, provision servers, and attach the key — ensuring every deployed instance is accessible for post-deployment configuration or debugging.
* **Rotate SSH Keys Across Your Server Fleet** As part of a key rotation policy, create a new SSH key pair and use this endpoint to assign it to all affected servers. Once confirmed, remove the old key pair. The array-based `serverId` parameter makes it efficient to update multiple servers in a single call.

## Getting Required Parameters

* **subscriptionId** (query): Retrieve available subscription IDs using the [List all Subscriptions](https://gitlab.com/plenit-group/plenit-docs-es-es/-/blob/v1.0/reference/listallsubscriptions/README.md) endpoint. Pass your `organizationId` as a query parameter to list all subscriptions, then use the `id` field from the response.
* **sshId** (path): Retrieve available SSH key pair IDs using the [List SSH Key Pairs by Subscription](https://gitlab.com/plenit-group/plenit-docs-es-es/-/blob/v1.0/reference/listsshkeypairsbysubscription/README.md) endpoint. Pass the `subscriptionId` as a query parameter to get all key pairs in that subscription, then use the `id` field from the response.
* **serverId** (body): Retrieve available server IDs using the [Get All Servers for a Subscription Id](https://gitlab.com/plenit-group/plenit-docs-es-es/-/blob/v1.0/reference/getallserversbysubscription/README.md) endpoint. Pass the `subscriptionId` as a query parameter to list all servers, then use the `id` field of each target server. This parameter accepts an array, so you can include multiple server IDs in a single request.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.plenit.com/docs-en/reference/servers-api/sshkeypair/addsshkeypairtoserver.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
