Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

API endpoint to generate SSH keys for Pipelines

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

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
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,453 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you