ssh-keys Resource

Overview

Use the ssh-keys resource to manipulate the ssh-keys on an individual or team account. The ssh-key fields are the following:

Field Description
pk The key identifier (ID).
key Public key value.
label The user-visible label on the key.

You cannot update an existing ssh-key.  Instead, you must DELETE the key and recreate a new one with a POST call.

GET /users/{accountname}/ssh-keys

Gets a list of the keys associated with an account. This call requires authentication. This call takes the following parameters:

Parameter Required? Description
accountname Yes The name of an individual or team account.
GET https://api.bitbucket.org/1.0/users/{accountname}/ssh-keys
  Click here to expand the response...
[
    {
        "pk": 171052,
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMl/FZf5AtrJBth+8swfDfJrRWetHHnew/LTwX86OGdcG4sJWE5QpWzO9K+szpxaFmMF729
bKAUBMBWNoPrYApayyalirpe7fjzHqIWoq5CsP/wKDVSyMxVOiBwBnXSukS7i9iOiC2J5PyEQwAq7GJXI3E2UWyymW7rVyaDdYKLH9PdUMNmLfBpsDUyjdGO40pLj
r6KCiyOTLI07Qy5iVz44VTRm6IBlxhee0DV3gw4GADHllSRVVOOngO+3453543sgfsfgsgsffgs3345345DFG346qi4WTeECB6JH87Fhd
CGS6mFyavpvOnrZdR9jGD auserbb",
        "label": "home"
    }
]

POST /users/{accountname}/ssh-keys

Creates a key on the specified account. You must supply a valid key that is unique across the Bitbucket service. A public key contains characters need to be escaped before sending it as a POST data. So, use the proper escaping ( urlencode ), if you are testing to add a key via your terminal. This call requires authentication. 

This call takes the following parameters:

Parameter Required? Description
accountname Yes The name of an individual or team account.
label No A label for the key.
key Yes The key value.
POST https://api.bitbucket.org/1.0/users/{accountname}/ssh-keys --data "key=value"
  Click here to expand the response...
[
    {
        "pk": 171052,
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMl/FZf5AtrJBth+8swfDfJrRWetHHnew/LTwX86OGdcG4sJWE5QpWzO9K+szpxaFmMF729
bKAUBMBWNoPrYApayyalirpe7fjzHqIWoq5CsP/wKDVSyMxVOiBwBnXSukS7i9iOiC2J5PyEQwAq7GJXI3E2UWyymW7rVyaDdYKLH9PdUMNmLfBpsDUyjdGO40pLj
r6KCiyOTLI07Qy5iVz44VTRm6IBlxhee0DV3gw4GADHllSRVVOOngO+3453543sgfsfgsgsffgs3345345DFG346qi4WTeECB6JH87Fhd
CGS6mFyavpvOnrZdR9jGD auserbb",
        "label": "home"
    }
]

GET /users/{accountname}/ssh-keys/{key_id}

Gets the content of the specified key_id. This call requires authentication. This call requires authentication and takes the following parameters:

Parameter Required? Description
accountname Yes The name of an individual or team account.
key_id Yes The key identifier. This is an internal value created by Bitbucket when the key is added.
label No The label for the key.
GET https://api.bitbucket.org/1.0/users/{accountname}/ssh-keys/{key_id}
  Click here to expand...
[
    {
        "pk": 171052,
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMl/FZf5AtrJBth+8swfDfJrRWetHHnew/LTwX86OGdcG4sJWE5QpWzO9K+szpxaFmMF729
bKAUBMBWNoPrYApayyalirpe7fjzHqIWoq5CsP/wKDVSyMxVOiBwBnXSukS7i9iOiC2J5PyEQwAq7GJXI3E2UWyymW7rVyaDdYKLH9PdUMNmLfBpsDUyjdGO40pLj
r6KCiyOTLI07Qy5iVz44VTRm6IBlxhee0DV3gw4GADHllSRVVOOngO+3453543sgfsfgsgsffgs3345345DFG346qi4WTeECB6JH87Fhd
CGS6mFyavpvOnrZdR9jGD auserbb",
        "label": "home"
    }
]

DELETE /users/{accountname}/ssh-keys/{key_id}

Deletes the key specified by the key_id value. This call requires authentication and takes the following parameters:

Parameter Required? Description
accountname Yes The name of an individual or team account.
key_id Yes The key identifier.
DELETE https://api.bitbucket.org/1.0/users/{accountname}/ssh-keys/{key_id}
  Click here to expand...
[
    {
        "pk": 171052,
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMl/FZf5AtrJBth+8swfDfJrRWetHHnew/LTwX86OGdcG4sJWE5QpWzO9K+szpxaFmMF729
bKAUBMBWNoPrYApayyalirpe7fjzHqIWoq5CsP/wKDVSyMxVOiBwBnXSukS7i9iOiC2J5PyEQwAq7GJXI3E2UWyymW7rVyaDdYKLH9PdUMNmLfBpsDUyjdGO40pLj
r6KCiyOTLI07Qy5iVz44VTRm6IBlxhee0DV3gw4GADHllSRVVOOngO+3453543sgfsfgsgsffgs3345345DFG346qi4WTeECB6JH87Fhd
CGS6mFyavpvOnrZdR9jGD auserbb",
        "label": "home"
    }
]

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport