You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
To upload an SSH access key for a project, the REST API endpoint to use is:
POST /rest/keys/1.0/projects/{projectKey}/ssh
With a payload similar to the following payload:
{
"key": {
"text": "ssh-rsa AAAAB3... me@127.0.0.1"
},
"permission": "PROJECT_READ"
}
To add an SSH access key to a repository, we can use:
POST /rest/keys/1.0/projects/{projectKey}/repos/{repositorySlug}/ssh
And this payload:
{
"key": {
"text": "ssh-rsa AAAAB3... me@127.0.0.1"
},
"permission": "REPO_WRITE"
}
And finally to add an SSH personal key for a user, this is the command:
POST /rest/ssh/1.0/keys?user=username
With a payload similar to:
{
"text": "ssh-rsa AAAAB3... me@127.0.0.1"
}
When using curl, the full command to add an SSH access key on a project looks like this:
curl --user <user>:<password> -H "Content-Type: application/json" --data @input.json -X POST <Bitbucket URL>/rest/keys/1.0/projects/{projectKey}/repos/{repositorySlug}/ssh
There are two different types of SSH keys that can be set up as described on the Controlling access to code and Using SSH keys to secure Git operations:
Both of these access keys can be managed by using the REST API endpoints described on the Bitbucket Server - SSH page.
Just one of the multiple set of endpoints available on the Bitbucket Server REST APIs list.
Caterina Curti
Developer Advocate
Sydney
100 accepted answers
0 comments