SSH access keys for system use
Note that Bitbucket Server supports DSA, RSA2, and Ed25519 key types. RSA1 is not supported.
Before you can use SSH keys to secure a connection with Bitbucket Server the following must have already been done:
- Your Bitbucket Server administrator must have already enabled SSH access, on Bitbucket Server.
- Your Bitbucket administrator must already have enabled the option SSH access keys enabled on Bitbucket.
- You must have already created an SSL key. See Creating SSH keys. Alternatively, you can use an existing key, if it isn't already being used for a personal account in Bitbucket Server.
Using SSH keys to allow access to Bitbucket Server repositories
To get the SSH key to work with your build, or other, system, you need to:
- Add the private key to that system. For Bamboo, see this page: Shared credentials.
- Add the public key to Bitbucket Server as described here:
Add an SSH access key to either a Bitbucket Server project or repository
You simply copy the public key, from the system for which you want to allow access, and paste it into Bitbucket Server.
Copy the public key. One approach is to display the key on-screen using
cat
, and copy it from there:cat < ~/.ssh/id_rsa.pub
Now, in Bitbucket Server, go to the Settings tab for the project or repository.
Click Access keys and then Add key.
- Choose the Read permission, for
git pull
orgit clone
operations for example, where you want to be sure that the system will not be able to write back to the Bitbucket Server repository.
Choose the Read / Write permission, forgit push
orgit merge
operations for example, where you may want your build system to merge successful feature branch builds to the default branch in the Bitbucket Server repository, or so that deployments can be tagged.
Note that if you attempt to add a key already present on a project or repository but with a different permission to what it currently has, the permission will simply be updated. Paste the key into the text box and click Add key.
Bitbucket Server license implications
- System access keys do not require an additional Bitbucket Server user license.
Reusing access keys
- You can use the same SSH access key for multiple repositories or projects.
- Keys used for personal user accounts can't be re-used as a project or repository system access key, and keys used as a project or repository access key can't be re-used for user accounts.
Deleting an access key
You can delete an access key by going to Settings > Access keys for the repository, and clicking the cross for the key (the cross only appears when you move the mouse pointer there):
If the key is used for multiple projects or repositories, you can select the other places that you want the key to be deleted from:
Note that the dialog only displays the projects and repositories that you have permission to see. Be aware that the key may also be used in other places that are not listed in the dialog. To be 100% sure that all uses of the key are deleted, this operation must be performed by someone with the administrator or sysadmin global permission.
Note that Bitbucket Server supports DSA, RSA2, and Ed25519 key types. RSA1 is not supported.