Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (2024)

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (2)

If you’re using Bitbucket for version control, setting up an SSH key is a secure way to interact with your repositories. Follow these steps to generate an SSH key:

Open a terminal on your local machine.

Step 2.1: Generate the SSH Key
Run the following command to generate a new SSH key:

ssh-keygen -t ed25519 -C "your_email@example.com"

Other key types are as follows:

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (3)

Step 2.2: Use Existing Keys
If you have existing keys, you can also use them. For listing existing keys;

ls -al ~/.ssh
Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (4)

To view one of the available keys;
cat [ssh-key-path]

cat /Users/fd/.ssh/id_ed25519.pub
Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (5)

Click on the Personal BitBucket Settings menu.

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (6)

Click on the SSH Keys menu under Security and click on the Add Key button on the page that opens.

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (7)

In the window that opens, add the SSH Key. (You can get the SSH key with cat [ssh-key-path] command. — Step 2.2.)

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (8)

To clone your project, click the Clone button on the bitbucket project repository page.

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (9)

Select SSH from the window that opens. You have two options here. You can clone it by typing the code it gives you in your terminal. Or you can clone it directly with VS Code by pressing the “Clone in VS Code” button.

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (10)

To verify that the key is set up correctly, run the following command:

ssh -T git@bitbucket.org
Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (11)

If everything is configured correctly, you should receive a successful connection message.

Now, you’ve successfully generated or used existing SSH keys for Bitbucket, providing a secure way to interact with your repositories.

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket (2024)

FAQs

Creating an SSH Key for Bitbucket & Clone Project with SSH Key from Bitbucket? ›

SSH Client Keys

Bitbucket supports four encryption algorithms for client keys: Ed25519, ECDSA, RSA, and DSA. The following table shows the supported key types and the minimum key size for each supported key type. Bitbucket Cloud only accepts public keys in OpenSSH's authorized_keys format.

How to create a SSH key for Bitbucket? ›

To add an SSH key to your user account:
  1. Select the Settings cog on the top navigation bar.
  2. From the Settings dropdown menu, select Personal Bitbucket settings.
  3. Under Security, select SSH keys.
  4. Select Add key.
  5. In the Add SSH key dialog, provide a Label to help you identify which key you are adding.

How to create a SSH key? ›

For Windows 10 & 11
  1. Press the Windows key or open up the Start Menu. Type “cmd”.
  2. Under “Best Match”, click “Command Prompt”.
  3. In the command prompt, use the ssh-keygen command: ...
  4. The system will now generate the key pair and display the key fingerprint and a randomart image. ...
  5. Open your file explorer.

How to clone with specific SSH key? ›

To clone a project from GitHub using an SSH key, follow these steps:
  1. Create an SSH key on your local machine if you don't have one already. Open a terminal and enter the following command: ...
  2. Add the SSH key to your GitHub account. ...
  3. Ensure your Git client is set up to use SSH. ...
  4. Clone the GitHub repository using the SSH URL.

What SSH keys are supported by bitbucket? ›

SSH Client Keys

Bitbucket supports four encryption algorithms for client keys: Ed25519, ECDSA, RSA, and DSA. The following table shows the supported key types and the minimum key size for each supported key type. Bitbucket Cloud only accepts public keys in OpenSSH's authorized_keys format.

How to clone using SSH key bitbucket? ›

Follow these steps to generate an SSH key:
  1. Step 1: Open a Terminal. Open a terminal on your local machine.
  2. Step 2: Generate the SSH Key or Use Existing Keys. Step 2.1: Generate the SSH Key. ...
  3. Step 3: Add the Key to Bitbucket. ...
  4. Step 4: Cloning a Bitbucket Project to local with SSH Key. ...
  5. Step 5: Test the Connection.
Feb 14, 2024

Where to find project key in bitbucket? ›

Bitbucket - How to add bitbucket project key

The first step is to Open Bitbucket, and Click Projects. Click the project you want to use for this. Click Project settings. Click Access keys.

How to clone using SSH? ›

How to Set Up SSH and Clone Repository Using SSH in Git
  1. Set up SSH. Step 1: Generate SSH Key Pair. Step 2: Add Key To GitHub. Step 3: Test the Connection. Step 4: Check Local SSH Agent. ...
  2. Clone Repository Using SSH Protocol. Step 1: Go to Repository Page. Step 2: Obtain SSH URL. Step 3: Clone Repository.
  3. Cloning with SSH vs. HTTPS.
Nov 2, 2023

How to generate SSH key and copy? ›

Copy the ssh key into remote servers
  1. Open a terminal on your local computer.
  2. Generate an SSH key pair if you haven't already done so by running the command: ssh-keygen . ...
  3. Once the key pair is generated, run the command: ssh-copy-id user@remote_server . ...
  4. You'll be prompted to enter the password for the remote user account.
Apr 8, 2023

How do I create a SSH host key? ›

To generate an SSH key on your Linux server, run the command ssh-keygen . The command can take flags if you would like to customize the type of key that is generated and the signing algorithms that are used to generate the key. This example generates a standard 2048-bit RSA key without a passphrase.

How to SSH with a specific SSH key? ›

To specify which private key should be used for connections to a particular remote host, use a text editor to create a ~/. ssh/config that includes the Host and IdentityFile keywords. Once you save the file, SSH will use the specified private key for future connections to that host.

Do I need SSH key to clone? ›

Ease of setup: Cloning with HTTPS is straightforward and doesn't require setting up SSH keys. Universally accessible: HTTPS cloning works through firewalls and proxy servers.

How to add a key to a ssh agent? ›

Adding SSH Key to SSH Agent
  1. Check if SSH Agent is running. eval "$(ssh-agent -s)"
  2. Add the Keys to SSH Agent. ssh-add ~/.ssh/nameofkey.
  3. Verify Keys Added to SSH Agent. ssh-add -l.
  4. Copy Key to Remote Server. ssh-copy-id user@remote.server.location.
  5. Copy Server Key to Host. ssh-copy-id user@host.local.
Mar 22, 2022

How to create an SSH key for Bitbucket? ›

SSH key config with BitBucket steps
  1. Locally create a pair of private and public SSH keys with the ssh-keygen tool.
  2. Copy the value of the public SSH key.
  3. Log into BitBucket and navigate to your Personal Settings.
  4. Click the SSH Keys link.
  5. Add your BitBucket SSH Key to your Atlassian configuration.
Jan 14, 2022

How do you create a SSH key? ›

Generate an SSH Key Pair
  1. Run the ssh-keygen command. You can use the -t option to specify the type of key to create. ...
  2. The command prompts you to enter the path to the file in which you want to save the key. ...
  3. The command prompts you to enter a passphrase. ...
  4. When prompted, enter the passphrase again to confirm it.

How do I check if my SSH key is working in bitbucket? ›

You can test your key from the command shell by typing the command ssh git@bitbucket.com and entering your passphrase. You should get a message that indicates that the authentication worked but that you don't have shell access.

How do I add a SSH key label in Bitbucket? ›

From Bitbucket, click Add key. Enter a Label for your new key, for example, Default public key . Paste the copied public key into the SSH Key field. It doesn't matter whether or not you include the email address in the Key.

How to create SSH deploy key? ›

Set up deploy keys
  1. Run the ssh-keygen procedure on your server, and remember where you save the generated public and private rsa key pair.
  2. On GitHub.com, navigate to the main page of the repository.
  3. Under your repository name, click Settings. ...
  4. In the sidebar, click Deploy Keys.
  5. Click Add deploy key.

How to use SSH key in Bitbucket pipeline? ›

Add the key as a secure variable
  1. In the Bitbucket repository, select Repository settings, then under Pipelines, select Repository variables.
  2. Copy the base64-encoded private key from the terminal.
  3. Paste the encoded key as the value for an environment variable. Make sure to check Secured.

Top Articles
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 5330

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.