DEV Community

Mikaeel Khalid
Mikaeel Khalid

Posted on • Originally published at blog.mikaeels.com on

How to Setup/Enable BitBucket Terminal Access on a Mac

Image description

Setting up an SSH key can be a confusing and tedious process, but it doesn't have to be. This blog post will show you a simple and straightforward method for installing an SSH key on your Mac.

Step 1: Generate the SSH Key

To generate your SSH key, open a Terminal window and type:

~ ssh-keygen
Enter fullscreen mode Exit fullscreen mode

Press enter a few times to go through the prompts. This will create two files in a hidden folder in your home directory, called "id_rsa" & "id_rsa.pub." You can verify that the files have been created by typing:

~ ls ~/.ssh
Enter fullscreen mode Exit fullscreen mode

id_rsa id_rsa.pub

in the Terminal.

Step 2: Add the Key to SSH-Agent

To ensure that macOS remembers to use your SSH key after a restart, you will need to add it to the SSH-Agent. To do this, type:

~ eval ssh-agent
Enter fullscreen mode Exit fullscreen mode

Agent pid xxxx

in the Terminal, then:

~ ssh-add -K ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode

to add the key to the agent.

Step 3: Remember After Restart

To make sure that your config file is set up correctly, type:

~ touch ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

and

~ open ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

in the Terminal. This will open the config file in a text editor. Ensure the config file includes the following lines:

Host * 
UseKeychain yes
Enter fullscreen mode Exit fullscreen mode

Step 4: Add Public Key to BitBucket

To add your public key to BitBucket, copy the key to the clipboard by typing:

~ pbcopy < ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

in the Terminal. Then, go to this URL: https://bitbucket.org/account/settings/ssh-keys/ and click "Add Key." Paste the key into the textbox and add a label (e.g. "MacBook Key").

Step 5: Verify Everything Works

To verify that your SSH key is working correctly, type:

~ ssh -T git@bitbucket.org | grep logged
Enter fullscreen mode Exit fullscreen mode

in the Terminal. If everything is set up correctly, you should see the message "logged in as [YOUR USERNAME]."

Following these simple steps, you can easily set up an SSH key on your Mac and start accessing your BitBucket repositories through the terminal. No more confusion or long-winded instructions!

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more