DEV Community

Aneeqa Khan
Aneeqa Khan

Posted on

Setting up SSH key for Bitbucket account on macOS

Hi all, today I want to share how to generate a SSH key and set it for the Bitbucket repository.

Introduction

An SSH key is an access credential for the SSH (secure shell) network protocol. This authenticated and encrypted secure network protocol is used for remote communication between machines on an unsecured open network. SSH key is used for remote file transfer, network management, and remote operating system access.

Generate SSH key

Open your terminal and paste the below command in the root directory.

ssh-keygen -t rsa
Enter fullscreen mode Exit fullscreen mode

Then it will ask where to save the key file. You can press enter to save it on the default location.

Set Passphrase

Next, it will ask you to set Passphrase for that file. You can keep it empty but it is recommended to set the Passphrase because the SSH key without a Passphrase can be used by anyone to access the system or repository.

Copy SSH key

Now paste the below command to get the public access key you just created

cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

Note: Here id_rsa.pub is SSH key file name.

Set it on Bitbucket

  • Open your Bitbucket account and go to Personal settings.
  • Select SSH keys under the Security tab.
  • Press Add key button. It will open the below-mentioned dialog box for you. bitbucket img
  • Here paste that copied key type the label and press Add key button to save it on your Bitbucket settings.

Now you can access the repository with a secure connection. Thank you for reading!

Discussion (0)