ec2.key-pairs.import

Register an existing SSH public key

POST /ec2/api/key-pairsIAM ec2:ImportKeyPairChanges state

One store with `kms ssh-key-pairs` (list, generate, sync from a password manager): the pair is the same object there, under the same id.

Request syntax

POST /ec2/api/key-pairs
{
  "name": "string",
  "regionId": "string",
  "publicKey": "string",
  "tags": "map of string"
}

Request body

  • nameRequired

    string

    A display name

    Constraints: 1-64 chars

  • regionIdOptional

    string

    Ignored: an SSH key is not regional. Kept for old clients

    Constraints: min 1 chars

  • publicKeyRequired

    string

    The public key in OpenSSH format, e.g. "ssh-ed25519 AAAA… comment"

    Constraints: min 1 chars

  • tagsOptional

    map of string

    Tags for the new resource, e.g. {"env": "prod", "project": "shop"}. Keys your organization marks required must be present, or the create is refused with the missing keys (GET /tags/api/keys lists them).

    Constraints: key=value

Response

201: `data` is the key pair: id, name, publicKey, fingerprint (SHA256:…), keyType (ed25519 or rsa).

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow ec2:ImportKeyPair on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud ec2 key-pairs import --name example --public-key example

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_ec2_key-pairs_import.