Regenerate SSH keys for Bitbucket Data Center
Regenerating the key for a single repository
When viewing the settings for linked, project, or plan repositories stored in Bitbucket Data Center, you may see an error message stating that Bamboo couldn’t access the repository. One of the potential reasons for this issue could be missing SSH keys.
To regenerate the SSH key for an affected repository, navigate to the repository configuration page and select Save repository without making any changes to the settings.
Bamboo will attempt to repair the connection to the repository. If the problem persists, it may mean that the repository may have been moved or deleted or that the respective instance of Bitbucket is inaccessible.
Learn more about configuring source code repositories
Bulk regenerating SSH keys
If SSH keys are missing from many repositories and potentially across multiple linked instances of Bitbucket Data Center, you can repair them in bulk using the following Bamboo REST API endpoints.
These operations performed by these endpoints will only add the missing keys and will not replace existing, working ones. Performing key repair operations requires Administrator permissions.
Depending on the number of Bitbucket Data Center instances and repositories to process, bulk key regeneration may take a long time to complete.
Regenerating keys for all linked instances of Bitbucket Data Center
To regenerate the keys for all affected repositories in all linked instances of Bitbucket Data Center, call the following Bamboo REST API endpoint:
POST /rest/stash/latest/bulk/keys/repair
Include an empty request body in your API call.
Regenerating keys for a specific instance of Bitbucket Data Center
To regenerate the keys for all affected repositories in a single, specific linked instance of Bitbucket Data Center, call the following Bamboo REST API endpoint:
POST /rest/stash/latest/bulk/keys/repair/<APPLICATION_LINK_ID>
Include an empty request body in your API call.
To obtain a particular application link ID, use the following command to get the list of all linked Bitbucket Data Center instances together with their application link IDs:
curl -H "Content-Type: application/json" -H "Accept: application/json" http://<BAMBOO_URL>/rest/stash/latest/servers
Response
The responses to the previously described REST calls come in the form of an execution log with information about the processing status of each repository.
Optional filtering parameters
Both endpoints include optional filtering parameters in the request payload to help with narrowing the number of repositories to process:
Parameter | Type | Description | Default value |
---|---|---|---|
search | string | Case-insensitive phrase to search for in repository names. | Empty |
skipLinked | boolean | Skip linked repositories. | false |
skipPlan | boolean | Skip plan-based repositories. | false |
skipProject | boolean | Skip project repositories. | false |
selectedProjects | array[string] | List of case-insensitive project keys whose project repositories should be included. By default, all projects are included. | Empty |
selectedPlans | array[string] | Case-insensitive list of plan keys whose plan repositories should be included. By default, all plans are included. | Empty |
For example, the request payload may look like this:
{
"search": "bamboo",
"skipLinked": false,
"skipProject": false,
"skipPlan": true,
"selectedProjects": ["PROJECTKEY1", "PROJECTKEY2"]
}