Skip to content
  • Auto
  • Light
  • Dark

List

List All SSH Keys
gpu_droplets.account.keys.list(KeyListParams**kwargs) -> KeyListResponse
get/v2/account/keys

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.

ParametersExpand Collapse
page: Optional[int]

Which 'page' of paginated results to return.

minimum1
per_page: Optional[int]

Number of items returned per page

minimum1
maximum200
ReturnsExpand Collapse
class KeyListResponse:

Information about the response itself.

total: Optional[int]

Number of objects returned by the request.

Accepts one of the following:

URI of the last page of the results.

URI of the next page of the results.

URI of the first page of the results.

URI of the previous page of the results.

ssh_keys: Optional[List[SSHKeys]]
name: str

A human-readable display name for this key, used to easily identify the SSH keys when they are displayed.

public_key: str

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.

id: Optional[int]

A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet.

fingerprint: Optional[str]

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.

List All SSH Keys
from gradient import Gradient

client = Gradient()
keys = client.gpu_droplets.account.keys.list()
print(keys.meta)
{
  "meta": {
    "total": 1
  },
  "links": {
    "pages": {
      "last": "https://api.digitalocean.com/v2/images?page=2",
      "next": "https://api.digitalocean.com/v2/images?page=2"
    }
  },
  "ssh_keys": [
    {
      "name": "My SSH Public Key",
      "public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"
    }
  ]
}
Returns Examples
{
  "meta": {
    "total": 1
  },
  "links": {
    "pages": {
      "last": "https://api.digitalocean.com/v2/images?page=2",
      "next": "https://api.digitalocean.com/v2/images?page=2"
    }
  },
  "ssh_keys": [
    {
      "name": "My SSH Public Key",
      "public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"
    }
  ]
}