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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.