---
title: "POST /v1/{+environment}:addPublicKey"
method: POST
path: "/v1/{+environment}:addPublicKey"
tags: ["users"]
---

# POST /v1/{+environment}:addPublicKey

`POST /v1/{+environment}:addPublicKey`

Adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via SSH. If a key with the same content already exists, this will error with ALREADY_EXISTS.

## Path parameters

- `environment` string, required

## Request body

- AddPublicKeyRequest — Request message for AddPublicKey.
  - `key` string — Key that should be added to the environment. Supported formats are `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256` (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as <format> <content>, where <content> part is encoded with Base64.

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/cloudshell.md) · [All operations](https://skmtc.dev/google/apis/cloudshell/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/cloudshell/revisions/4fa0d8d99f5e/schema)
