SSH user keys for personal use
- ED25519
- RSA2
- ECDSA
- DSA (we recommend you use other key types)
- ED25519-SK
- ECDSA-SK
Although Bitbucket supports the above key types, your admin can restrict specific key types and mandate minimum key lengths to make sure you’re using secure SSH keys. Learn more about how your admin can manage settings for SSH keys
注意:
- A Bitbucket user can add any number of keys to their account.
- 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 access key, and keys used as a project or repository access key can't be re-used for user accounts.
- If you've already cloned a repository, you'll need to make sure you’re accessing it via the SSH URL. Learn more about how Git remote works
Add an SSH key to your Bitbucket account
On Windows, in your command prompt, change directory to your .ssh directory, and copy the public key file to your clipboard by running:
Windowscd %userprofile%/.ssh clip < id_ed25519.pub
On macOS or Linux simply run the following in a terminal:Mac OS Xpbcopy < ~/.ssh/id_ed25519.pub
If
pbcopy
isn't working, locate the hidden.ssh
folder, open the file in a text editor, and copy it to your clipboard.
Note that on Linux, you may need to download and install xclip, then use that, as shown in this code snippet:Linuxsudo apt-get install xclip xclip -sel clip < ~/.ssh/id_ed25519.pub
In Bitbucket, go to your account:
- Select Manage account.
- Click on SSH keys and then Add key.
- Paste the key into the text box:
- (Optional) Name your key to identify it easily.
- (Optional) Set an expiry so your key expires automatically.
If your admin has set automatic expiry for all keys across Bitbucket, the key expires based on the limits they've set. If required, you can set the key to expire earlier than the limit they've set.
Note that you can't edit the expiry after you create the key. - Click Add key. You're done!
Use SSH keys to connect to Bitbucket repositories
SSH access needs to have been set up, as described above. Once this is done, you can use SSH keys as follows:
- Go to Projects, click a project, and choose a repository from the list.
- Click Clone in the sidebar to see the clone URLs for the repository.
- Choose the clone URL you want to use. SSH is available if you have already added an SSH key to your account. If you haven't done that yet, see Add an SSH key to your Bitbucket account, above.