Regenerate SSH keys for Bitbucket Data Center and Server
Regenerating the key for a single repository
When viewing the settings for linked, project, or plan repositories stored in Bitbucket Data Center and Server, 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 and Server, 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.
Bulk SSH key regeneration is available in Bamboo 9.1.x starting from release 9.1.1.
Depending on the number of Bitbucket Data Center and Server 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 and Server
To regenerate the keys for all affected repositories in all linked instances of Bitbucket Data Center and Server, 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 and Server
To regenerate the keys for all affected repositories in a single, specific linked instance of Bitbucket Data Center and Server, 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 and Server instances together with their application link IDs:
curl -H "Content-Type: application/json" -H "Accept: application/json" http://<BAMBOO_URL>/rest/stash/latest/servers
レスポンス
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:
パラメーター | タイプ | 説明 | 既定値 |
---|---|---|---|
search | 文字列 | Case-insensitive phrase to search for in repository names. | 空 |
skipLinked | ブーリアン | Skip linked repositories. | false |
skipPlan | ブーリアン | Skip plan-based repositories. | false |
skipProject | ブーリアン | 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. | 空 |
selectedPlans | array[string] | Case-insensitive list of plan keys whose plan repositories should be included. By default, all plans are included. | 空 |
For example, the request payload may look like this:
{
"search": "bamboo",
"skipLinked": false,
"skipProject": false,
"skipPlan": true,
"selectedProjects": ["PROJECTKEY1", "PROJECTKEY2"]
}