SSH Keys

SSHKey

class doapi.SSHKey[source]

An SSH key resource, representing an SSH public key that can be automatically added to the /root/.ssh/authorized_keys files of new droplets.

New SSH keys are created via the doapi.create_ssh_key() method and can be retrieved with the doapi.fetch_ssh_key() and doapi.fetch_all_ssh_keys() methods.

The DigitalOcean API specifies the following fields for SSH key objects:

Variables:
  • id (int) – a unique identifier for the SSH key
  • fingerprint (string) – the unique fingerprint of the SSH key
  • name (string) – a human-readable name for the SSH key
  • public_key (string) – the entire SSH public key as it was uploaded to DigitalOcean
__int__()

Convert the resource to its unique integer ID

__str__()[source]

Convert the SSH key to its fingerprint

url

The endpoint for general operations on the individual SSH key

fetch()[source]

Fetch & return a new SSHKey object representing the SSH key’s current state

Return type:SSHKey
Raises:DOAPIError – if the API endpoint replies with an error (e.g., if the SSH key no longer exists)
update_ssh_key(name)[source]

Update (i.e., rename) the SSH key

Parameters:name (str) – the new name for the SSH key
Returns:an updated SSHKey object
Return type:SSHKey
Raises:DOAPIError – if the API endpoint replies with an error
delete()[source]

Delete the SSH key

Returns:None
Raises:DOAPIError – if the API endpoint replies with an error