Keypairs (SSH keys)

The keypairs resource can be used to store ssh keys, for use with your servers. You have the choice whether to store only the public key or the full public-private key keypair. Keys attached to a server appear in the server context, and for OS images, which support cloudinit, they can also be automatically added to authorized_keys on a reboot. If you omit the public and private keys when creating a keypair, a new rsa keypair will be automatically generated for you. Having the private key in your profile will allow for using a web-based ssh client. It is also useful if your OS does not have key generation tools installed.

If the user has turned on two-factor authentication, the keypairs resource is protected with one time password. In order to make key management for servers easier (and not requiring OTP), there is pubkeys resource, which is a read-only version of the keypairs resource. The pubkeys objects are identical to keypairs except for the fact that they do not contain the private key, and have a has_private_key attribute instead of private_key, which indicates whether the private key was set.

Creating a keypair

POST /keypairs/

You have three choices when creating a keypair:

  • Provide both private and public key
  • Provide only a public key, in which case the private key will remain empty
  • Provide no public, neither private key, in which case a new pair will be generated for you

Here is an example of providing both pairs:

POST /api/2.0/keypairs/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "name": "test_pub",
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXwIBAAKCAIEAuU+9enw6UwtDPW+82mLpkEKitLn1drCWuLvWdhdeCfMUCVAL\nZAQiQZkzwyD6xxav2uRyzP3P7nLGuFD/bF+xqL6qq/7KvqzKb79SfLYEOLrpLAwB\n+8AXgNtLXZHEE0KTBIGpT9I/RKXfeWZAmQWSigTREjuuAOQcby7tb4IgoisCAwEA\nAQKCAIBl9QORUqxcaIP0V3gWx/kt0BvpR69QQFSNC3wxuSWaX82UWiAKRWP7p6kd\nIRYZV9glnS+0rakrzqabXqVKIVSDTbHT7SbP56t2pjfi/se/zTQeWYz65AGIfJV4\nNa8e3qN6ivMjTHHgvjbpFIjnFyO5O173deQFSWZXH+l9DuGGUQJBANQVYJqqqGn9\nNCzdLaEnA/+FIPI2jNXxvSqWUr8JolOXaBqxJYUJZNaVFq80NspYJuNHkCaddq1K\nTBe5CEk1FXcCQQDfrysb6prO9Caduozt2ms1R06bVw1i89mn48RFylOHRLNm8Xm/\n+bQErrzFbrPgln7pTmszeBZdpP5ejVOqzxXtAkEAy4ikiGqFbApa+z9cng7icGOk\nJa+iY2Q25dsUGFC3nz9r4knltxI32xODjKswdeo5j99LATQXA+GMuyuRPyiZqwJA\nOXMD32eh2wVZ5ajECVLPth9aUQtKpN98R2J4RnRwf41lhkr+ug+n7Iv0b8C+8i+0\n6Lb7UXzGQcbejeo+UuBdAQJBAMY5mf78YtmOW4i2kPYkS8wsjr9IE1ewUKezBSjj\nTHHog0pafFboifN/aFoO/jL1v7+8XLZ+uZwx5hPQ1L9fzO8=\n-----END RSA PRIVATE KEY-----\n",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC5T716fDpTC0M9b7zaYumQQqK0ufV2sJa4u9Z2F14J8xQJUAtkBCJBmTPDIPrHFq/a5HLM/c/ucsa4UP9sX7Govqqr/sq+rMpvv1J8tgQ4uuksDAH7wBeA20tdkcQTQpMEgalP0j9Epd95ZkCZBZKKBNESO64A5BxvLu1vgiCiKw=="
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "fingerprint": "79:20:0b:49:72:11:b1:bc:df:73:94:09:3d:f8:90:71",
            "grantees": [],
            "meta": {},
            "name": "test_pub",
            "permissions": [],
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXwIBAAKCAIEAuU+9enw6UwtDPW+82mLpkEKitLn1drCWuLvWdhdeCfMUCVAL\nZAQiQZkzwyD6xxav2uRyzP3P7nLGuFD/bF+xqL6qq/7KvqzKb79SfLYEOLrpLAwB\n+8AXgNtLXZHEE0KTBIGpT9I/RKXfeWZAmQWSigTREjuuAOQcby7tb4IgoisCAwEA\nAQKCAIBl9QORUqxcaIP0V3gWx/kt0BvpR69QQFSNC3wxuSWaX82UWiAKRWP7p6kd\nIRYZV9glnS+0rakrzqabXqVKIVSDTbHT7SbP56t2pjfi/se/zTQeWYz65AGIfJV4\nNa8e3qN6ivMjTHHgvjbpFIjnFyO5O173deQFSWZXH+l9DuGGUQJBANQVYJqqqGn9\nNCzdLaEnA/+FIPI2jNXxvSqWUr8JolOXaBqxJYUJZNaVFq80NspYJuNHkCaddq1K\nTBe5CEk1FXcCQQDfrysb6prO9Caduozt2ms1R06bVw1i89mn48RFylOHRLNm8Xm/\n+bQErrzFbrPgln7pTmszeBZdpP5ejVOqzxXtAkEAy4ikiGqFbApa+z9cng7icGOk\nJa+iY2Q25dsUGFC3nz9r4knltxI32xODjKswdeo5j99LATQXA+GMuyuRPyiZqwJA\nOXMD32eh2wVZ5ajECVLPth9aUQtKpN98R2J4RnRwf41lhkr+ug+n7Iv0b8C+8i+0\n6Lb7UXzGQcbejeo+UuBdAQJBAMY5mf78YtmOW4i2kPYkS8wsjr9IE1ewUKezBSjj\nTHHog0pafFboifN/aFoO/jL1v7+8XLZ+uZwx5hPQ1L9fzO8=\n-----END RSA PRIVATE KEY-----\n",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC5T716fDpTC0M9b7zaYumQQqK0ufV2sJa4u9Z2F14J8xQJUAtkBCJBmTPDIPrHFq/a5HLM/c/ucsa4UP9sX7Govqqr/sq+rMpvv1J8tgQ4uuksDAH7wBeA20tdkcQTQpMEgalP0j9Epd95ZkCZBZKKBNESO64A5BxvLu1vgiCiKw==",
            "resource_uri": "/api/2.0/keypairs/fdd6fbba-644b-49d8-9324-ff6589179da3/",
            "tags": [],
            "uuid": "fdd6fbba-644b-49d8-9324-ff6589179da3"
        }
    ]
}

Here is an example of providing only a public key:

POST /api/2.0/keypairs/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "name": "test_another_pub",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDFGtYDl+/Oua9uBXqwcbE84QUBBbDdMMzaZ6MAGg1Bmus9VEW0P8kK6npZ0SaUnB2xRrBNwCv0Q0uZBJ70UicgsrhBjCXIVa7K6yQYrFzMxfN8saNAjJvGDdWGSvcMxJdpYwXiOQhFan36eJCCwQjni7I538Ii9chPD8/tyJcBIw=="
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "fingerprint": "e8:ee:43:72:38:09:6d:1e:8e:46:9e:76:80:a3:0a:01",
            "grantees": [],
            "meta": {},
            "name": "test_another_pub",
            "permissions": [],
            "private_key": null,
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDFGtYDl+/Oua9uBXqwcbE84QUBBbDdMMzaZ6MAGg1Bmus9VEW0P8kK6npZ0SaUnB2xRrBNwCv0Q0uZBJ70UicgsrhBjCXIVa7K6yQYrFzMxfN8saNAjJvGDdWGSvcMxJdpYwXiOQhFan36eJCCwQjni7I538Ii9chPD8/tyJcBIw==",
            "resource_uri": "/api/2.0/keypairs/6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244/",
            "tags": [],
            "uuid": "6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244"
        }
    ]
}

Here is an example of creating an autogenerated pair:

POST /api/2.0/keypairs/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "name": "test_name"
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
            "grantees": [],
            "meta": {},
            "name": "test_name",
            "permissions": [],
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47cd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sVTH4TYDDGlK+COtP1PKSygcP8abG/oQ/eCdt\nJ3Bmo5Ju2BqwEaI4YjKttUlxoYEZOtEWDL+8bF27xsz13C/j5LRd51MJhKgVI0sy\nJ9FkZM7K0GTZ743r/yzxwWh98QKCAIBTQKv4M4E5/1y75yenEXhGTfm8YnRNTlrO\npzEgV+o51mJ7KFj8G5Z4mSGy5Ygp2XlkNAEnnvZEMnxtkOlRFC/wexufPO2c6Edw\nd/oOvZ7qI4fDqVoxvAv+hrL36bJxKWUulOEgcFrViH5KlUc0YkQkAJSf7YIcuNdL\nJbpQHBLKYQKCAIBj9rEmDdnGqoseRMLZPXduUHdv6bXhmsw9jVIlB088sg19ZSW/\nng4UvesHB3vSylZIEYhEdnIBqlc84XeXEMRSYVZ9x+RMDP5jJ44Uq52iGYarIhwg\nW8m4q0JmhnPM0M3fRQxbIXOaUQvDgjGuLlzDCY9JjiEfyTgMJATNKK2O4Q==\n-----END RSA PRIVATE KEY-----\n",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzjTryYVIZObTbmhqdVKmK3JmOL/ZLcDSNElbWS7jtx36lEGWP2TZzbMLjM8EvYR5jxE0ys39GosgFTQuwf0tnqbtB4VXCDYfRJZ2HiOgXPNwtGSTyyG/HniXboCFpzU7CHzIRGfK6bWZujhUikmMFTHZd3oe6RcMi8Ftb9/F7co7usws1K2TEAJK5GYZf5Sm0xzUzQHfB2keYYSwuImftGzUIzyBBLqIjzwTLB/66x1oczN/zDayMLvCaUp9g0pTCdChQIyHCjrjokJ0Trvbnzg5d2Yb5qo72s1zGFu2JWKiMuuRxsu2wch2fiVS9Tl07H+JQv4fm9G90fBOkdlpj",
            "resource_uri": "/api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
            "tags": [],
            "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
        }
    ]
}

Listing, Getting, Updating, Deleting

List keypairs:

GET /keypairs/
GET /api/2.0/keypairs/?limit=0 HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "meta": {
        "limit": 0,
        "offset": 0,
        "total_count": 2
    },
    "objects": [
        {
            "fingerprint": "8c:71:a2:f0:bc:a4:45:66:a8:59:77:6d:80:d5:a0:89",
            "grantees": [],
            "meta": {},
            "name": "ala",
            "permissions": [],
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEqQIBAAKCAQEAvROcpJ/0T5iZUzfRydsJI4zCbuQAfGH3Bl/biggPY1atLqzf\niz6lctY8wsz2sYts9OQomtCB/xtMPfUjHZpLg1EP4/hfP1NCWtsIbIiDYKrzNEFg\nApSO1AkqBZ8tVL2gpPUuSdaK5P3lPjkbt43dgnThIyMvNoi0g7ngC6L6s960JvBq\nuamOvd8wVaW/VpbyZrKqRwvmsMH1pGErhSAeErImOdwM8wtCddLS3O4nxfts06py\nEcGhupvH8lph9q+jKJxpg7whUkOJyZoMN1XgDvtRFbz9PvlxqP0SOecEHP+4yCOg\nDcJa69LSFFxmlSog9BitCv5qRFwrvKGsMYcesQIDAQABAoIBAQCYBufhend/dIx7\n3BsDuemMOwavEQbO/BoadwLX5okw76WKLRgFJxby0g3C9/i3Ywr1kWqQqGyOCY3x\nF2TnzYNAD/K985vqF/D3irwoQE+ab3njn1kqWfbJyKCQKp/RTjOXz0gruKSvYPJt\naI+/tALSfVX04bp5l8vFSrQ5xw7bhiiFifATuDStVLSzzmEli6Pbne4mcKIXiReu\nK1OlSKPF9SbCxCcEvEhUhQqs7U/N+sEYmUSQ/q8rNdolWQD0c/EGn2RF0siNolxp\nylo5c7E/LvwgTW6DLYaEZDgORnYHEwiaG7YxJAuFFPoQNFIjoGEF5wKOGL/kKtVr\npyriY/k9AoIAgQDRKEf+B+SLO/P/rPP7CCCIh4tR9uXl6hbnEp40sx5AomZmIwfy\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+ORu3jd2CdOEjIy82iLSDueALovqz3rQm8Gq5qY693zBVpb9WlvJmsqpHC+awwfWkYSuFIB4SsiY53AzzC0J10tLc7ifF+2zTqnIRwaG6m8fyWmH2r6MonGmDvCFSQ4nJmgw3VeAO+1EVvP0++XGo/RI55wQc/7jII6ANwlrr0tIUXGaVKiD0GK0K/mpEXCu8oawxhx6x",
            "resource_uri": "/api/2.0/keypairs/186106ac-afb5-40e5-a0de-6f0feba5a3d5/",
            "tags": [],
            "uuid": "186106ac-afb5-40e5-a0de-6f0feba5a3d5"
        },
        {
            "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
            "grantees": [],
            "meta": {},
            "name": "test_name",
            "permissions": [],
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47cd+pRBl\nj9k2c2zC4zPBL2EeY8RNMrN/RqLIBU0LsH9LZ6m7QeFVwg2H0SWdh4joFzzcLRkk\n8shvx54l26Ahac1Owh8yERnyum1mbo4VIpJjBUx2Xd6HukXDIvBbW/fxe3KO7rML\nNStkxACSuRmGX+UptMc1M0B3wdpHmGEsLiJn7Rs1CM8gQS6iI88Eywf+usdaHMzf\n8w2sjC7wmlKfYNKUwnQoUCMhwo646JCdE672584OXdmG+aqO9rNcxhbtiViojLrk\ncbLtsHIdn4lUvU5dOx/iUL+H5vRvdHwTpHZaYwIDAQABAoIBAAadFyTCbPG87GqC\nXKSa77vLsGRKY/oXYfgoSsaN93vas1GFLxiDWbwar3sK9vy1yRbHrkhF0FRbvp5j\nXiDcL3zcBafBkxUYxn3vssPBSTtB5KJMoM3IkEV8D8ztMw3goBwKZh+3Ive2++Tq\nmuCxH7CcRmfiwIEd/LgWvma+1UhEuisw2y9F+m9Xl4TRwt34utyyVcjKDPH146W9\ne2ZyFwAcvDOTA8oI+txgA57m284QqHo04YHZdbPN3ovPBNwpfKCpNjneab91fTXX\nX48RY7O1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ZLcDSNElbWS7jtx36lEGWP2TZzbMLjM8EvYR5jxE0ys39GosgFTQuwf0tnqbtB4VXCDYfRJZ2HiOgXPNwtGSTyyG/HniXboCFpzU7CHzIRGfK6bWZujhUikmMFTHZd3oe6RcMi8Ftb9/F7co7usws1K2TEAJK5GYZf5Sm0xzUzQHfB2keYYSwuImftGzUIzyBBLqIjzwTLB/66x1oczN/zDayMLvCaUp9g0pTCdChQIyHCjrjokJ0Trvbnzg5d2Yb5qo72s1zGFu2JWKiMuuRxsu2wch2fiVS9Tl07H+JQv4fm9G90fBOkdlpj",
            "resource_uri": "/api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
            "tags": [],
            "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
        }
    ]
}

Get a single keypair:

GET /keypairs/{uuid}/
GET /api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
    "grantees": [],
    "meta": {},
    "name": "test_name",
    "permissions": [],
    "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47cd+pRBl\nj9k2c2zC4zPBL2EeY8RNMrN/RqLIBU0LsH9LZ6m7QeFVwg2H0SWdh4joFzzcLRkk\n8shvx54l26Ahac1Owh8yERnyum1mbo4VIpJjBUx2Xd6HukXDIvBbW/fxe3KO7rML\nNStkxACSuRmGX+UptMc1M0B3wdpHmGEsLiJn7Rs1CM8gQS6iI88Eywf+usdaHMzf\n8w2sjC7wmlKfYNKUwnQoUCMhwo646JCdE672584OXdmG+aqO9rNcxhbtiViojLrk\ncbLtsHIdn4l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gcFrViH5KlUc0YkQkAJSf7YIcuNdL\nJbpQHBLKYQKCAIBj9rEmDdnGqoseRMLZPXduUHdv6bXhmsw9jVIlB088sg19ZSW/\nng4UvesHB3vSylZIEYhEdnIBqlc84XeXEMRSYVZ9x+RMDP5jJ44Uq52iGYarIhwg\nW8m4q0JmhnPM0M3fRQxbIXOaUQvDgjGuLlzDCY9JjiEfyTgMJATNKK2O4Q==\n-----END RSA PRIVATE KEY-----\n",
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzjTryYVIZObTbmhqdVKmK3JmOL/ZLcDSNElbWS7jtx36lEGWP2TZzbMLjM8EvYR5jxE0ys39GosgFTQuwf0tnqbtB4VXCDYfRJZ2HiOgXPNwtGSTyyG/HniXboCFpzU7CHzIRGfK6bWZujhUikmMFTHZd3oe6RcMi8Ftb9/F7co7usws1K2TEAJK5GYZf5Sm0xzUzQHfB2keYYSwuImftGzUIzyBBLqIjzwTLB/66x1oczN/zDayMLvCaUp9g0pTCdChQIyHCjrjokJ0Trvbnzg5d2Yb5qo72s1zGFu2JWKiMuuRxsu2wch2fiVS9Tl07H+JQv4fm9G90fBOkdlpj",
    "resource_uri": "/api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
    "tags": [],
    "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
}

Update a kypair:

PUT /keypairs/{uuid}/
PUT /api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
    "grantees": [],
    "meta": {},
    "name": "new_name",
    "permissions": [],
    "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47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ByCsVTH4TYDDGlK+COtP1PKSygcP8abG/oQ/eCdt\nJ3Bmo5Ju2BqwEaI4YjKttUlxoYEZOtEWDL+8bF27xsz13C/j5LRd51MJhKgVI0sy\nJ9FkZM7K0GTZ743r/yzxwWh98QKCAIBTQKv4M4E5/1y75yenEXhGTfm8YnRNTlrO\npzEgV+o51mJ7KFj8G5Z4mSGy5Ygp2XlkNAEnnvZEMnxtkOlRFC/wexufPO2c6Edw\nd/oOvZ7qI4fDqVoxvAv+hrL36bJxKWUulOEgcFrViH5KlUc0YkQkAJSf7YIcuNdL\nJbpQHBLKYQKCAIBj9rEmDdnGqoseRMLZPXduUHdv6bXhmsw9jVIlB088sg19ZSW/\nng4UvesHB3vSylZIEYhEdnIBqlc84XeXEMRSYVZ9x+RMDP5jJ44Uq52iGYarIhwg\nW8m4q0JmhnPM0M3fRQxbIXOaUQvDgjGuLlzDCY9JjiEfyTgMJATNKK2O4Q==\n-----END RSA PRIVATE KEY-----\n",
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzjTryYVIZObTbmhqdVKmK3JmOL/ZLcDSNElbWS7jtx36lEGWP2TZzbMLjM8EvYR5jxE0ys39GosgFTQuwf0tnqbtB4VXCDYfRJZ2HiOgXPNwtGSTyyG/HniXboCFpzU7CHzIRGfK6bWZujhUikmMFTHZd3oe6RcMi8Ftb9/F7co7usws1K2TEAJK5GYZf5Sm0xzUzQHfB2keYYSwuImftGzUIzyBBLqIjzwTLB/66x1oczN/zDayMLvCaUp9g0pTCdChQIyHCjrjokJ0Trvbnzg5d2Yb5qo72s1zGFu2JWKiMuuRxsu2wch2fiVS9Tl07H+JQv4fm9G90fBOkdlpj",
    "resource_uri": "/api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
    "tags": [],
    "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
    "grantees": [],
    "meta": {},
    "name": "new_name",
    "permissions": [],
    "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47cd+pRBl\nj9k2c2zC4zPBL2EeY8RNMrN/RqLIBU0LsH9LZ6m7QeFVwg2H0SWdh4joFzzcLRkk\n8shvx54l26Ahac1Owh8yERnyum1mbo4VIpJjBUx2Xd6HukXDIvBbW/fxe3KO7rML\nNStkxACSuRmGX+UptMc1M0B3wdpHmGEsLiJn7Rs1CM8gQS6iI88Eywf+usdaHMzf\n8w2sjC7wmlKfYNKUwnQoUCMhwo646JCdE672584OXdmG+aqO9rNcxhbtiViojLrk\ncbLtsHIdn4lUvU5dOx/iUL+H5vRvdHwTpHZaYwIDAQABAoIBAAadFyTCbPG87GqC\nXKSa77vLsGRKY/oXYfgoSsaN93vas1GFLxiDWbwar3sK9vy1yRbHrkhF0FRbvp5j\nXiDcL3zcBafBkxUYxn3vssPBSTtB5KJMoM3IkEV8D8ztMw3goBwKZh+3Ive2++Tq\nmuCxH7CcRmfiwIEd/LgWvma+1UhEuisw2y9F+m9Xl4TRwt34utyyVcjKDPH146W9\ne2ZyFwAcvDOTA8oI+txgA57m284QqHo04YHZdbPN3ovPBNwpfKCpNjneab91fTXX\nX48RY7O1MpDdvbE4l3ELptJq/E74xRsmsZziwRVAV0X6Eb6B2s/0xvKG2/+eDZz7\n1c/gG/ECggCBAMx6111Xtptw93dNZpYBHGNoulh+jn9p8RLIrbpOCncZ0v7EMdV1\n8TYgEDQ0n5TuUx501jWKTNbvoXyTUsAUkvA7VyyH2o8UTtqPgRi8ShB+DePZmRt8\nCwHzjUo86N4BnD6rcfFlFvQMzHRcAmvLrkMtkImgQHFHHh/JjMDjweYdAoIAgQDg\nyn8qWgueIPphlLW6vP9oL+01dHKU3oDlhtUME6/cOwZtzex4tRmx3NbIN/lpfRS7\ndVczIjwcGwHb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ypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
    "tags": [],
    "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
}

Delete a keypair:

DELETE /keypairs/{uuid}/
DELETE /api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop
HTTP/1.1 204 NO CONTENT
Content-Type: text/html; charset=utf-8

Pubkeys resource

In order to access just the public keys without the need for OTP, you can use the pubkeys resource. Instead of a private key it contains an attribute has_private_key which indicates whether the private key was set.

For example creating an autogenerated keypair:

POST /api/2.0/keypairs/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "name": "test_name"
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "fingerprint": "99:1e:71:ea:d1:43:80:55:14:ca:27:5c:64:69:3b:10",
            "grantees": [],
            "meta": {},
            "name": "test_name",
            "permissions": [],
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAs4068mFSGTm025oanVSpityZji/2S3A0jRJW1ku47cd+pRBl\nj9k2c2zC4zPBL2EeY8RNMrN/RqLIBU0LsH9LZ6m7QeFVwg2H0SWdh4joFzzcLRkk\n8shvx54l26Ahac1Owh8yERnyum1mbo4VIpJjBUx2Xd6HukXDIvBbW/fxe3KO7rML\nNStkxACSuRmGX+UptMc1M0B3wdpHmGEsLiJn7Rs1CM8gQS6iI88Eywf+usdaHMzf\n8w2sjC7wmlKfYNKUwnQoUCMhwo646JCdE672584OXdmG+aqO9rNcxhbtiViojLrk\ncbLtsHIdn4lUvU5dOx/iUL+H5vRvdHwTpHZaYwIDAQABAoIBAAadFyTCbPG87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rEmDdnGqoseRMLZPXduUHdv6bXhmsw9jVIlB088sg19ZSW/\nng4UvesHB3vSylZIEYhEdnIBqlc84XeXEMRSYVZ9x+RMDP5jJ44Uq52iGYarIhwg\nW8m4q0JmhnPM0M3fRQxbIXOaUQvDgjGuLlzDCY9JjiEfyTgMJATNKK2O4Q==\n-----END RSA PRIVATE KEY-----\n",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzjTryYVIZObTbmhqdVKmK3JmOL/ZLcDSNElbWS7jtx36lEGWP2TZzbMLjM8EvYR5jxE0ys39GosgFTQuwf0tnqbtB4VXCDYfRJZ2HiOgXPNwtGSTyyG/HniXboCFpzU7CHzIRGfK6bWZujhUikmMFTHZd3oe6RcMi8Ftb9/F7co7usws1K2TEAJK5GYZf5Sm0xzUzQHfB2keYYSwuImftGzUIzyBBLqIjzwTLB/66x1oczN/zDayMLvCaUp9g0pTCdChQIyHCjrjokJ0Trvbnzg5d2Yb5qo72s1zGFu2JWKiMuuRxsu2wch2fiVS9Tl07H+JQv4fm9G90fBOkdlpj",
            "resource_uri": "/api/2.0/keypairs/b4fa47cf-f929-4dde-b77a-ea1d326862bd/",
            "tags": [],
            "uuid": "b4fa47cf-f929-4dde-b77a-ea1d326862bd"
        }
    ]
}

Results in a corresponding pubkeys object with has_private_key, which is true:

GET /api/2.0/pubkeys/fdd6fbba-644b-49d8-9324-ff6589179da3/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "fingerprint": "79:20:0b:49:72:11:b1:bc:df:73:94:09:3d:f8:90:71",
    "grantees": [],
    "has_private_key": true,
    "meta": {},
    "name": "test_pub",
    "permissions": [],
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC5T716fDpTC0M9b7zaYumQQqK0ufV2sJa4u9Z2F14J8xQJUAtkBCJBmTPDIPrHFq/a5HLM/c/ucsa4UP9sX7Govqqr/sq+rMpvv1J8tgQ4uuksDAH7wBeA20tdkcQTQpMEgalP0j9Epd95ZkCZBZKKBNESO64A5BxvLu1vgiCiKw==",
    "resource_uri": "/api/2.0/pubkeys/fdd6fbba-644b-49d8-9324-ff6589179da3/",
    "tags": [],
    "uuid": "fdd6fbba-644b-49d8-9324-ff6589179da3"
}

Creating a keypair with only a public key:

POST /api/2.0/keypairs/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "name": "test_another_pub",
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDFGtYDl+/Oua9uBXqwcbE84QUBBbDdMMzaZ6MAGg1Bmus9VEW0P8kK6npZ0SaUnB2xRrBNwCv0Q0uZBJ70UicgsrhBjCXIVa7K6yQYrFzMxfN8saNAjJvGDdWGSvcMxJdpYwXiOQhFan36eJCCwQjni7I538Ii9chPD8/tyJcBIw=="
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "fingerprint": "e8:ee:43:72:38:09:6d:1e:8e:46:9e:76:80:a3:0a:01",
            "grantees": [],
            "meta": {},
            "name": "test_another_pub",
            "permissions": [],
            "private_key": null,
            "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDFGtYDl+/Oua9uBXqwcbE84QUBBbDdMMzaZ6MAGg1Bmus9VEW0P8kK6npZ0SaUnB2xRrBNwCv0Q0uZBJ70UicgsrhBjCXIVa7K6yQYrFzMxfN8saNAjJvGDdWGSvcMxJdpYwXiOQhFan36eJCCwQjni7I538Ii9chPD8/tyJcBIw==",
            "resource_uri": "/api/2.0/keypairs/6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244/",
            "tags": [],
            "uuid": "6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244"
        }
    ]
}

Results in a corresponding pubkeys object with has_private_key, which is false:

GET /api/2.0/pubkeys/6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "fingerprint": "e8:ee:43:72:38:09:6d:1e:8e:46:9e:76:80:a3:0a:01",
    "grantees": [],
    "has_private_key": false,
    "meta": {},
    "name": "test_another_pub",
    "permissions": [],
    "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDFGtYDl+/Oua9uBXqwcbE84QUBBbDdMMzaZ6MAGg1Bmus9VEW0P8kK6npZ0SaUnB2xRrBNwCv0Q0uZBJ70UicgsrhBjCXIVa7K6yQYrFzMxfN8saNAjJvGDdWGSvcMxJdpYwXiOQhFan36eJCCwQjni7I538Ii9chPD8/tyJcBIw==",
    "resource_uri": "/api/2.0/pubkeys/6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244/",
    "tags": [],
    "uuid": "6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244"
}

Attaching pubkeys to a server

You can attach the keys to a server definition on the pubkeys attribute. They are made available to the VM OS via the server context.

Here is an example of doing that using the keys created in the above section:

POST /api/2.0/servers/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "objects": [
        {
            "cpu": 1000,
            "cpu_type": "amd",
            "drives": [],
            "hypervisor": "kvm",
            "mem": 1073741824,
            "name": "test_srv_test_pubkeys",
            "nics": [
                {
                    "ip_v4_conf": {
                        "conf": "dhcp"
                    },
                    "model": "virtio"
                }
            ],
            "pubkeys": [
                "fdd6fbba-644b-49d8-9324-ff6589179da3",
                "6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244"
            ],
            "vnc_password": "7b08b0f03aa840ff"
        }
    ]
}
HTTP/1.1 201 CREATED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "context": true,
            "cpu": 1000,
            "cpu_model": null,
            "cpu_type": "amd",
            "cpus_instead_of_cores": false,
            "drives": [],
            "enable_numa": false,
            "grantees": [],
            "hv_relaxed": false,
            "hv_tsc": false,
            "hypervisor": "kvm",
            "jobs": [],
            "mem": 1073741824,
            "meta": {},
            "name": "test_srv_test_pubkeys",
            "nics": [
                {
                    "boot_order": null,
                    "firewall_policy": null,
                    "ip_v4_conf": {
                        "conf": "dhcp",
                        "ip": null
                    },
                    "ip_v6_conf": null,
                    "mac": "22:30:3d:8a:b6:59",
                    "model": "virtio",
                    "runtime": null,
                    "vlan": null
                }
            ],
            "owner": {
                "resource_uri": "/api/2.0/user/c2fc9982-cf2e-434a-bf63-e22a27b39f00/",
                "uuid": "c2fc9982-cf2e-434a-bf63-e22a27b39f00"
            },
            "permissions": [],
            "pubkeys": [
                {
                    "resource_uri": "/api/2.0/pubkeys/fdd6fbba-644b-49d8-9324-ff6589179da3/",
                    "uuid": "fdd6fbba-644b-49d8-9324-ff6589179da3"
                },
                {
                    "resource_uri": "/api/2.0/pubkeys/6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244/",
                    "uuid": "6d7db550-d1c5-4e3b-9c0a-e83f6a2b8244"
                }
            ],
            "requirements": [],
            "resource_uri": "/api/2.0/servers/f400243b-7005-4222-b319-dff0a376c4ea/",
            "runtime": null,
            "smp": 1,
            "status": "stopped",
            "tags": [],
            "uuid": "f400243b-7005-4222-b319-dff0a376c4ea",
            "vnc_password": "7b08b0f03aa840ff"
        }
    ]
}