---
title: "Create or import SSH key"
method: POST
path: "/v1/ssh-keys"
tags: ["SSH keys"]
---

# Create or import SSH key

`POST /v1/ssh-keys`

## Request

- Base URL: `https://api.emma.ms/external`
- URL: `https://api.emma.ms/external/v1/ssh-keys`
- Auth: HTTP bearer

This method creates an SSH key that can be used for Linux compute instance creation. An SSH key can be created in two ways: generated by emma or imported by the user.

If you want to **generate** a key, specify two fields: name and keyType (RSA or ED25519). The key will be generated, and you will receive a private key in the response. The private key will be shown only once, so copy and save it to connect to the Linux compute instances.

If you want to **import** an existing SSH key, specify two fields: name and key. In the key field, insert your public SSH key as a string. It will be imported.

## Request body

- union
  - SshKeyCreate
    - `name` string, required: SSH key name
    - `keyType` 'RSA' | 'ED25519', required: SSH key type (RSA or ED25519)
  - SshKeyImport
    - `name` string, required: SSH key name
    - `key` string, required: SSH public key

## Response `201`

Successful operation

- union
  - SshKey
    - `id` integer: SSH key ID
    - `name` string: SSH key name
    - `key` string: SSH public key
    - `fingerprint` string: SSH key fingerprint
    - `keyType` string: SSH key type (RSA or ED25519)
    - `createdAt` string: Date and time when the SSH key was created
    - `createdByName` string: Name of the user who created the SSH key
    - `createdById` integer: ID of the user who created the SSH key
  - SshKeyGenerated
    - `id` integer: SSH key ID
    - `name` string: SSH key name
    - `key` string: SSH public key
    - `fingerprint` string: SSH key fingerprint
    - `keyType` string: SSH key type (RSA or ED25519)
    - `privateKey` string: SSH private key
    - `createdAt` string: Date and time when the SSH key was created
    - `createdByName` string: Name of the user who created the SSH key
    - `createdById` integer: ID of the user who created the SSH key

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `403`: Forbidden - Access is denied
- `500`: Internal server error

---

[API](https://skmtc.dev/emma/apis/public-emma-api.md) - [All operations](https://skmtc.dev/emma/apis/public-emma-api/llms.txt) - [OpenAPI document](https://skmtc.dev/emma/apis/public-emma-api/revisions/9e55f0920078?raw)
