API: SSH Keys
The sshkey category lets you add SSH keys so that VMs can be provisioned with key-based authentication.
| Action | Required Parameters | Optional Parameters |
|---|---|---|
| sshkey/add | label, sshkey | None |
| sshkey/list | None | None |
| sshkey/remove | key_id | None |
sshkey/add
Required parameters:
- label - a label for this SSH key.
- sshkey - the public key data, e.g. 'ssh-rsa AAAAB3NzaC1yc2EA ... aPJTJDEREcZ3r'
Here is an example adding the LunaNode staff SSH key at https://www.lunanode.com/sshkey.txt:
Endpoint: sshkey/add
label=lunanode
sshkey=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/YL5kEqOHxWmSAneuhEkD6eEgbXh5ivE2XGQJaKvfWkaZ8n3fkPe/Um54Oaa0isSXKzslEEIvataysrk7QUgfsHfrNd/CayQmy+6xRj8sZjN92gHlA27rhJX007lG9O6VAVXBOtnlqdxbCh/MJkZWhLgJ5suoeNx1DIeUXjE3yw8jYbLBdDDW/zr+ewxJ9nxEtdz3TRnxoRST889ZzImS6Mz/7OxnibWzALyP0LXqM4WBmipdB/eRx1dQnIaWGgN+NTMlf0FGQCFmAT/veS75d+ZO310QdCz1dmOuW07+ECCnkqEmGUecv9Eli0DIw5Qa6w+ggEvaPJTJDEREcZ3r
{
"key_id": "1862",
"success": "yes"
}
sshkey/list
Endpoint: sshkey/list
{
"0": {
"id": "1862",
"name": "lunanode",
"value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/YL5kEqOHxWmSAneuhEkD6eEgbXh5ivE2XGQJaKvfWkaZ8n3fkPe/Um54Oaa0isSXKzslEEIvataysrk7QUgfsHfrNd/CayQmy+6xRj8sZjN92gHlA27rhJX007lG9O6VAVXBOtnlqdxbCh/MJkZWhLgJ5suoeNx1DIeUXjE3yw8jYbLBdDDW/zr+ewxJ9nxEtdz3TRnxoRST889ZzImS6Mz/7OxnibWzALyP0LXqM4WBmipdB/eRx1dQnIaWGgN+NTMlf0FGQCFmAT/veS75d+ZO310QdCz1dmOuW07+ECCnkqEmGUecv9Eli0DIw5Qa6w+ggEvaPJTJDEREcZ3r "
},
"success": "yes"
}
Response notes:
- The keys in the top-level dictionary are array indices and can be ignored; it is not the SSH key ID. To iterate over all key objects, take all the values of the top-level object except when key is 'success'.
- The SSH key ID is the value of the
idattribute in a key object. For instance, the ID above is 1862.
sshkey/remove
Required parameters:
- key_id - the SSH key ID.
Endpoint: sshkey/remove
key_id=1862
{"success": "yes"}