ssh_keys
Creates, updates, deletes, gets or lists a ssh_keys
resource.
Overview
Name | ssh_keys |
Type | Resource |
Id | digitalocean.compute.ssh_keys |
Fields
The following fields are returned by SELECT
queries:
- ssh_keys_get
- ssh_keys_list
A JSON object with the key set to ssh_key
. The value is an ssh_key
object containing the standard ssh_key
attributes.
Name | Datatype | Description |
---|---|---|
id | integer | A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. |
name | string | A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. (example: My SSH Public Key) |
fingerprint | string | A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. (example: 3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa) |
public_key | string | The entire public key string that was uploaded. Embedded into the root user's authorized_keys file if you include this key during Droplet creation. (example: ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example) |
A JSON object with the key set to ssh_keys
. The value is an array of ssh_key
objects, each of which contains the standard ssh_key
attributes.
Name | Datatype | Description |
---|---|---|
id | integer | A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. |
name | string | A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. (example: My SSH Public Key) |
fingerprint | string | A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. (example: 3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa) |
public_key | string | The entire public key string that was uploaded. Embedded into the root user's authorized_keys file if you include this key during Droplet creation. (example: ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
ssh_keys_get | select | ssh_key_identifier | To get information about a key, send a GET request to /v2/account/keys/$KEY_ID or /v2/account/keys/$KEY_FINGERPRINT .The response will be a JSON object with the key ssh_key and value an ssh_key object which contains the standard ssh_key attributes. | |
ssh_keys_list | select | per_page , page | To list all of the keys in your account, send a GET request to /v2/account/keys . The response will be a JSON object with a key set to ssh_keys . The value of this will be an array of ssh_key objects, each of which contains the standard ssh_key attributes. | |
ssh_keys_create | insert | data__public_key , data__name | To add a new SSH public key to your DigitalOcean account, send a POST request to /v2/account/keys . Set the name attribute to the name you wish to use and the public_key attribute to the full public key you are adding. | |
ssh_keys_update | replace | ssh_key_identifier | To update the name of an SSH key, send a PUT request to either /v2/account/keys/$SSH_KEY_ID or /v2/account/keys/$SSH_KEY_FINGERPRINT . Set the name attribute to the new name you want to use. | |
ssh_keys_delete | delete | ssh_key_identifier | To destroy a public SSH key that you have in your account, send a DELETE request to /v2/account/keys/$KEY_ID or /v2/account/keys/$KEY_FINGERPRINT .A 204 status will be returned, indicating that the action was successful and that the response body is empty. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
ssh_key_identifier |
| Either the ID or the fingerprint of an existing SSH key. (example: 512189) |
page | integer | Which 'page' of paginated results to return. (example: 1) |
per_page | integer | Number of items returned per page (example: 2) |
SELECT
examples
- ssh_keys_get
- ssh_keys_list
To get information about a key, send a GET request to /v2/account/keys/$KEY_ID
or /v2/account/keys/$KEY_FINGERPRINT
.
The response will be a JSON object with the key ssh_key
and value an ssh_key object which contains the standard ssh_key attributes.
SELECT
id,
name,
fingerprint,
public_key
FROM digitalocean.compute.ssh_keys
WHERE ssh_key_identifier = '{{ ssh_key_identifier }}' -- required;
To list all of the keys in your account, send a GET request to /v2/account/keys
. The response will be a JSON object with a key set to ssh_keys
. The value of this will be an array of ssh_key objects, each of which contains the standard ssh_key attributes.
SELECT
id,
name,
fingerprint,
public_key
FROM digitalocean.compute.ssh_keys
WHERE per_page = '{{ per_page }}'
AND page = '{{ page }}';
INSERT
examples
- ssh_keys_create
- Manifest
To add a new SSH public key to your DigitalOcean account, send a POST request to /v2/account/keys
. Set the name
attribute to the name you wish to use and the public_key
attribute to the full public key you are adding.
INSERT INTO digitalocean.compute.ssh_keys (
data__public_key,
data__name
)
SELECT
'{{ public_key }}' --required,
'{{ name }}' --required
RETURNING
ssh_key
;
# Description fields are for documentation purposes
- name: ssh_keys
props:
- name: public_key
value: string
description: >
The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation.
- name: name
value: string
description: >
A human-readable display name for this key, used to easily identify the SSH keys when they are displayed.
REPLACE
examples
- ssh_keys_update
To update the name of an SSH key, send a PUT request to either /v2/account/keys/$SSH_KEY_ID
or /v2/account/keys/$SSH_KEY_FINGERPRINT
. Set the name
attribute to the new name you want to use.
REPLACE digitalocean.compute.ssh_keys
SET
data__name = '{{ name }}'
WHERE
ssh_key_identifier = '{{ ssh_key_identifier }}' --required
RETURNING
ssh_key;
DELETE
examples
- ssh_keys_delete
To destroy a public SSH key that you have in your account, send a DELETE request to /v2/account/keys/$KEY_ID
or /v2/account/keys/$KEY_FINGERPRINT
.
A 204 status will be returned, indicating that the action was successful and that the response body is empty.
DELETE FROM digitalocean.compute.ssh_keys
WHERE ssh_key_identifier = '{{ ssh_key_identifier }}' --required;