Adding a ssh key for bitbucket

First generate a key:

#ssh-keygen -t rsa
#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/id_bitbucket
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/id_bitbucket.
Your public key has been saved in /root/
The key fingerprint is:
3f:da [email protected]
The key's randomart image is:

Now, add the key to the ssh-agent:

ssh-add ~/.ssh/id_bitbucket

Oops, there’s an error!

Could not open a connection to your authentication agent.

Here’s the fix:

#exec ssh-agent bash

To make sure it does not happen again, add the following to .bashrc:

SSH_AUTH_SOCK=/tmp/ssh-qoIvoV8968/agent.8968; export SSH_AUTH_SOCK;

Now, add the key to the agent.

Now, add the key to bitbucket.

after printing the public key to your screen:

#cat /root/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCofxmd7nnaLx9aIjA5Q+U3gA2acUBvZy6NW+6kd3cqtb/QfLBVasjf/T6a7lVhNSlGYF25o+LhEJsz7A3JADXexG7VUQcuP1N4jkYlVDFx7KoLnS8tq9oaxMTwmjUMnsnJuKk+eE0y3omw3LcSf5ivAuuISd9BjlxuNHzpHHzZGZDorCEAUi2pzDerUNIbdxkaovCuERxys7ySnEChsj62auEEFN0wEKB4tW4uTLPq3XEfs3dK2RZkfjG9WTy6IoItrau9GMJPYVLVx2TFotiWCdwzbwpJHJXsQxmqdXoj3/SJgUIHNUK8oY8ykbPx9X7h/AI3xv41qwHw1A7LNePT [email protected]

Copy it entirely, including the [email protected] parameter at the end.

Now, on trying to clone a repo, it will just work.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.