SSH user keys for personal use

Still need help?

The Atlassian Community is here for you.

Ask the community

You can use SSH keys to establish a secure connection between your computer and Bitbucket Data Center when you are performing Git operations (pull, clone, push) from your local machine. In Bitbucket 8.15 and later, you can also use SSH keys to sign your commits and tags.

Personal keys are attached to your Bitbucket account – they are bound by that account's permissions and use the account's identity for any operations.

Before you can use SSH keys to secure a connection with Bitbucket the following must have already been done:

  • your Bitbucket administrator must have already enabled SSH access in Bitbucket.
  • you need an SSH key! See Creating SSH keys. Alternatively, you can use an existing key, if it isn't already being used as a repository or project access key.
  • you need to have added your personal SSH key to your Bitbucket account – see the following section.

Once you have an SSH key associated with your Bitbucket account, using it is easy! See Use SSH keys to connect to Bitbucket repositories below.

Bitbucket supports the following SSH key types:
  • ED25519
  • RSA2
  • DSA (we recommend you use other key types) 
  • ED25519-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

Note that:

  • 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

  1. On Windows, in your command prompt, change directory to your .ssh directory, and copy the public key file to your clipboard by running:

    cd %userprofile%/.ssh
    clip <

    On macOS or Linux simply run the following in a terminal:

    Mac OS X
    pbcopy < ~/.ssh/

    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:

    sudo apt-get install xclip
    xclip -sel clip < ~/.ssh/
  2. In Bitbucket, go to your profile picture and select Manage account.

    Profile picture_Manage accounts 

  3. Select SSH keys Add key. 

  4. Paste the key into the text box. 

  5. (Optional) Use the Key label field to name your key and identify it easily.
  6. (Optional) Set an expiry limit so your key expires automatically. If your admin has set automatic expiry for all keys across Bitbucket, the key will expire based on the configured limits. If required, you can set the key to expire earlier. Note that you can't edit the expiry limit after you create the key.  
  7. Select Add key. You're done!

After you create the key, it’ll be automatically assigned its own uneditable fingerprint – an SHA-256 hash for better readability. The fingerprint will replace the public key on the SSH keys list page, as well as display on the SSH key edit page and in the commit verification dialog.

List of SSH key fingerprints

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:

  1. Go to Projects, click a project, and choose a repository from the list.
  2. Click Clone in the sidebar to see the clone URLs for the repository.
  3. 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.
Last modified on Oct 16, 2023

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.