Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

API endpoint to generate SSH keys for Pipelines

Vincent D June 14, 2021

Hello, in an attempt to automatize everything, including repository pipeline configuration, I want to generate the SSH keys pair from the Bitbucket REST API.

I was able to set my own keys with https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines_config/ssh/key_pair#put

But on the UI we can just click "Generate keys". It would be very useful if we could just hit that with the REST API instead of providing our owns, but I couldn't find anything in the documentation about such endpoint. Any chance it gets implemented?

Thanks

1 answer

1 accepted

1 vote
Answer accepted
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 17, 2021

Hi @Vincent D ,

Thank you for your question!

As you could discover in the browser, UI uses the next url to generate ssh-keys pair:

curl -X POST -H "Content-Type: application/json" https://api.bitbucket.org/internal/repositories/{workspace}/{repo}/pipelines_config/ssh/key_pair/generate

response will returns public key that you could add to user, more details in the API docs Adds a new SSH public key to the specified user account

curl -X POST -H "Content-Type: application/json" -d '{"key": "public_key_content_here"}' https://api.bitbucket.org/2.0/users/{user_uuid}/ssh-keys

Required Scopes: account:write - Read and modify your account information

 

Note! Please, make sure, that you are realised that it's internal url, permanent work isn't guaranteed and could be changed any time.

 

Cheers,
Oleksandr Kyrdan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events