GET /api/users/:user_id/ssh_keys
List all SSH keys for a user

Examples

GET /api/users/988725723/ssh_keys
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "created_at": "2020-11-04 14:17:51 UTC",
      "updated_at": "2020-11-04 14:17:51 UTC",
      "id": 2,
      "name": "user3@example.com",
      "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDU6SP5IuFwTo3S8FO6toCoBhYrnrL+DTYUz9IykNuOxk3ws2ML1qsWC40sOV8DUNSZvfD7KOPorWHM0l5hdskJM5whWEBx/XmcdNlrrmLM+hh673eARx4umxq6LdAktNqkaAkyW2cQvCS6m0P+8/mcsfFAl/R2hZCHZuQJ99ohrFzY/HZ9jwiAxoZ20lf6MMBz4GfRd2aXvjyzmJ4bXEiy3tRkMy1+IzV20AhLgO4kEY46zT9qXkOgwKSS2Ufp4w5RKxMSTST7Gf/R9ltG27QhETWkAWm2eLleVU0+EGTsvSRltbyOnj71maxG1MHYv//NDKz9N6+im2+GSj5MObeT foreman2@example.com",
      "length": 2048,
      "fingerprint": "xpxdcLtz/cveE7rQI7EkFNxK+3bmmABlSUOZekBcnbc="
    }
  ]
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

user_id
required

ID of the user

Validations:

  • Must be a String

search
optional

filter results

Validations:

  • Must be a String

order
optional

Sort field and order, eg. ‘id DESC’

Validations:

  • Must be a String

page
optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
optional

Number of results per page to return, ‘all’ to return all results

Validations:

  • Must match regular expression /\A([1-9]\d|all)\Z$/.

Search fields

Field name Type Possible values
name string
user_id integer

GET /api/users/:user_id/ssh_keys/:id
Show an SSH key from a user

Examples

GET /api/users/988725726/ssh_keys/7-user6example-com
200
{
  "created_at": "2020-11-04 14:17:51 UTC",
  "updated_at": "2020-11-04 14:17:51 UTC",
  "id": 7,
  "name": "user6@example.com",
  "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc6nNKZZAuNGbXRhecmxcrSnn7aoHviRO7kI9EesFc2xAZN9ALUGWx8VTmt2GWoai8DWe4N/6LM8+SP4c/LEnYHG9eVfxuNKoBoWBQEYOJUksbEAin9wBcFOa5nLGaHTcBGpl75MotmRxJm5Pgc6jToUFnPe52S30z28vGg7Gh4VqsuiNM3ZZsHGZD6+I2SWz4ywGDW6sazCYIVbjDc45NYqmG4a+Sw94NWDVjjqZCYf0V1PQfCo7kTDD1UyLa/EIQ3794GgZLC/pJ24ZbDBJaEW1fuW+hFOQwxvC8Q3W361qjGg7E6hqXWK4kgONG0cw4GS3810bL/lwkatJ/MGTh foreman5@example.com",
  "length": 2048,
  "fingerprint": "o7yz9uV5hk02hk7q80I83t66VXeoHrvsKWBlwEgPgDs="
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

user_id
required

ID of the user

Validations:

  • Must be a String


POST /api/users/:user_id/ssh_keys
Add an SSH key for a user

Examples

POST /api/users/988725724/ssh_keys
{
  "name": "foreman@example.com",
  "key": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIhRoL6PfBRs9YwW3r2/pYeLrxRzEZSUO3Go8JivxMsguEKjJ3byHDPvPpMHhKKSZD/HJY/A+2Ndqp0ElB+t2qs= foreman@example.com",
  "ssh_key": {
    "name": "foreman@example.com",
    "key": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIhRoL6PfBRs9YwW3r2/pYeLrxRzEZSUO3Go8JivxMsguEKjJ3byHDPvPpMHhKKSZD/HJY/A+2Ndqp0ElB+t2qs= foreman@example.com"
  }
}
201
{
  "created_at": "2020-11-04 14:17:51 UTC",
  "updated_at": "2020-11-04 14:17:51 UTC",
  "id": 4,
  "name": "foreman@example.com",
  "key": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIhRoL6PfBRs9YwW3r2/pYeLrxRzEZSUO3Go8JivxMsguEKjJ3byHDPvPpMHhKKSZD/HJY/A+2Ndqp0ElB+t2qs= foreman@example.com",
  "length": 520,
  "fingerprint": "5YShdnIX3EEv8GzgY2BSVyOmR9ADnS71FpyobuNljxk="
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

user_id
required

ID of the user

Validations:

  • Must be a String

ssh_key
required

Validations:

  • Must be a Hash

ssh_key[name]
required

Validations:

  • Must be a String

ssh_key[key]
required

Public SSH key

Validations:

  • Must be a String


DELETE /api/users/:user_id/ssh_keys/:id
Delete an SSH key for a user

Examples

DELETE /api/users/988725722/ssh_keys/1-user2example-com
{
  "ssh_key": {}
}
200
{
  "id": 1,
  "name": "user2@example.com",
  "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDggz6N7Ki0HR8B81e5caLfKNYelu1NUK8XRhVO/xsI0wnURC1YYx13sGXDP+MogA9O8+Qq1jgtppuruyDBUZVNp5F8pa/jRgK9Htek6u0ZTuSnqQ8+Agc7GKduDDXF26iBTMoANL085cxoadl7qibWdzhEspI2TwVHklUMEQnGzRnJGUhgHT44lAKME32bZ73LO++7S8s0VpIfHg6PfaRQV8mM3yKUNVQHsJGGMXY9O4b1nQowxvYasIGU4NCHuRzi/hPtr1vLoRoyd1TOQ7jn0GOseAhlNJKsf93ibQVTZamFJsv/cVtCiYKtDBx5lb0LsqQHP0yZ9zn/ojsdhDR9 foreman1@example.com",
  "fingerprint": "rjjzIMKc2mG0jDUUtRnMLPf1AUlAqESSKqsq2aeqXK4=",
  "user_id": 988725722,
  "length": 2048,
  "created_at": "2020-11-04T14:17:50.812Z",
  "updated_at": "2020-11-04T14:17:50.812Z"
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

user_id
required

ID of the user

Validations:

  • Must be a String