SSH Keys

CloudsFor allows you to add SSH public keys to the interface so that you can embed your public key into a VM at the time of creation. Only the public key is required to take advantage of this functionality.

Attribute Type Description
id number
This is a unique identification number for the
key. This can be used to reference a specific SSH
key when you wish to embed a key into a VM.
fingerprint string
This attribute contains the fingerprint value that
is generated from the public key. This is a
unique identifier that will differentiate it from
other keys using a format that SSH recognizes.
public_key string
This attribute contains the entire public key
string that was uploaded. This is what is
embedded into the root user’s authorized_keys
file if you choose to include this SSH key during
VM creation.
name string
This is the human-readable display name for the
given SSH key. This is used to easily identify
the SSH keys when they are displayed.

List all Keys

To list all of the keys in your account, send a GET request to /api/v1/keys.

The response will be a JSON object with a key set to ssh_keys. The value of this will be an array of key objects, each of which contain the standard key attributes:

Attribute Type Description
id number
This is a unique identification number for the
key. This can be used to reference a specific SSH
key when you wish to embed a key into a VM.
fingerprint string
This attribute contains the fingerprint value that
is generated from the public key. This is a
unique identifier that will differentiate it from
other keys using a format that SSH recognizes.
public_key string
This attribute contains the entire public key
string that was uploaded. This is what is
embedded into the root user’s authorized_keys
file if you choose to include this SSH key during
VM creation.
name string
This is the human-readable display name for the
given SSH key. This is used to easily identify
the SSH keys when they are displayed.

cURL Example:

curl -X GET -H 'Content-Type: application/json' -u 'user@example.com:password' "https://cloudsfor.com/api/v1/keys"

Request Headers:

Content-Type: application/json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Response Headers:

content-type: application/json; charset=utf-8
status: 200 OK

Response Body:

{
  "ssh_keys": [
    {
      "id": "4322cb6b25774de1ad4f9a102c7d5424",
      "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
      "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
      "name": "My SSH Public Key"
    }
  ],
  "links": {
  },
  "meta": {
    "total": 1
  }
}

Create a new Key

To add a new SSH public key to your CloudsFor account, send a POST request to /api/v1/keys. Set the “name” attribute to the name you wish to use and the “public_key” attribute to a string of the full public key you are adding.

Name Type Description Required
name string The name to give the new SSH key in your account. true
public_key string A string containing the entire public key. true

The response body will be a JSON object with a key set to ssh_key. The value will be the complete generated key object. This will have the standard key attributes:

Attribute Type Description
id number
This is a unique identification number for the
key. This can be used to reference a specific SSH
key when you wish to embed a key into a VM.
fingerprint string
This attribute contains the fingerprint value that
is generated from the public key. This is a
unique identifier that will differentiate it from
other keys using a format that SSH recognizes.
public_key string
This attribute contains the entire public key
string that was uploaded. This is what is
embedded into the root user’s authorized_keys
file if you choose to include this SSH key during
VM creation.
name string
This is the human-readable display name for the
given SSH key. This is used to easily identify
the SSH keys when they are displayed.

cURL Example:

curl -X POST -H 'Content-Type: application/json' -u 'user@example.com:password' -d '{"name":"My SSH Public Key","public_key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"}' "https://cloudsfor.com/api/v1/keys"

Request Headers:

Content-Type: application/json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Request Body:

{
  "name": "My SSH Public Key",
  "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example"
}

Response Headers:

content-type: application/json; charset=utf-8
status: 201 Created

Response Body:

{
  "ssh_key": {
    "id": "4322cb6b25774de1ad4f9a102c7d5424",
    "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
    "name": "My SSH Public Key"
  }
}

Retrieve an existing Key

To show information about a key, send a GET request to /v1/keys/$KEY_ID. The response will be a JSON object with a key called ssh_key. The value of this will be a key object which contains the standard key attributes:

Attribute Type Description
id number
This is a unique identification number for the
key. This can be used to reference a specific SSH
key when you wish to embed a key into a VM.
fingerprint string
This attribute contains the fingerprint value that
is generated from the public key. This is a
unique identifier that will differentiate it from
other keys using a format that SSH recognizes.
public_key string
This attribute contains the entire public key
string that was uploaded. This is what is
embedded into the root user’s authorized_keys
file if you choose to include this SSH key during
VM creation.
name string
This is the human-readable display name for the
given SSH key. This is used to easily identify
the SSH keys when they are displayed.

cURL Example:

curl -X GET -H 'Content-Type: application/json' -u 'user@example.com:password' "https://cloudsfor.com/api/v1/keys/4322cb6b25774de1ad4f9a102c7d5424"

Request Headers:

Content-Type: application/json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Response Headers:

content-type: application/json; charset=utf-8
status: 200 OK

Response Body:

{
  "ssh_key": {
    "id": "4322cb6b25774de1ad4f9a102c7d5424",
    "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
    "name": "My SSH Public Key"
  }
}

Update a Key

To update the name of an SSH key, send a PUT request to /v1/keys/$SSH_KEY_ID. Set the “name” attribute to the new name you want to use.

Name Type Description Required
name string The name to give the new SSH key in your account. true

The response body will be a JSON object with a key set to ssh_key. The value will be an ojbect that contains the standard key attributes:

Attribute Type Description
id number
This is a unique identification number for the
key. This can be used to reference a specific SSH
key when you wish to embed a key into a VM.
fingerprint string
This attribute contains the fingerprint value that
is generated from the public key. This is a
unique identifier that will differentiate it from
other keys using a format that SSH recognizes.
public_key string
This attribute contains the entire public key
string that was uploaded. This is what is
embedded into the root user’s authorized_keys
file if you choose to include this SSH key during
VM creation.
name string
This is the human-readable display name for the
given SSH key. This is used to easily identify
the SSH keys when they are displayed.

cURL Example:

curl -X PUT -H 'Content-Type: application/json' -u 'user@example.com:password' -d '{"name":"Renamed SSH Key"}' "https://cloudsfor.com/api/v1/keys/4322cb6b25774de1ad4f9a102c7d5424"

Request Headers:

Content-Type: application/json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Request Body:

{
  "name": "Renamed SSH Key"
}

Response Headers:

content-type: application/json; charset=utf-8
status: 200 OK

Response Body:

{
  "ssh_key": {
    "id": "4322cb6b25774de1ad4f9a102c7d5424",
    "fingerprint": "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
    "name": "Renamed SSH Key"
  }
}

Destroy a Key

To destroy a public SSH key that you have in your account, send a DELETE request to /api/v1/keys/$KEY_ID.

A 204 status will be returned, indicating that the action was successful and that the response body is empty.

cURL Example:

curl -X DELETE -H 'Content-Type: application/json' -u 'user@example.com:password' "https://cloudsfor.com/api/v1/keys/4322cb6b25774de1ad4f9a102c7d5424"

Request Headers:

Content-Type: application/json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Response Headers:

content-type: application/octet-stream
status: 204 No Content