Setup ssh keys for Github and Bitbucket

Sangwin Gawande
2 min readJul 27, 2022

--

Setup ssh keys for Github and Bitbucket

It’s been years I am working as a web developer and there is still that small thing you need to do when you configure your new work machine.

shh key configuration (sigh). It’s fairly easy but becomes a nightmare when done wrong, especially when you are a newbie.

Now let’s get it over with

  1. Create a ssh key

Run the following command in the terminal for creating the ssh key

ssh-keygen -t rsa

After this step you’ll be asked to put name of the key and passphrase blah blah. Name the keys as ex. `bitbucket_key` or `github_key`, Get that done and move to next step.

2. Add ssh key command

ssh-add ~/.ssh/<your_ssh_key_name>

3. Add keys to the config file, mine looks like (choose better names)

Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/bitbucket_key
HostName github.com
HostName github.com
IdentityFile ~/.ssh/github_key
Host *
UseKeychain yes

4. Add public (.pub) keys to Github or Bitbucket Account

Github : Profile > Settings > SSH and GPG keys > New SSH key

Bitbucket : Personal Settings > SSH keys > Add key

Add key, give a name and copy .pub file contents here and SAVE.

5. Check if keys are working or not by running following commands

ssh -T git@bitbucket.org
ssh -T git@github.com

If you got the messages like above then you are good to go.!!

Happy Coding!!

Cheers!!

Sangwin Gawande

About me : https://sangw.in

--

--

No responses yet