Theoretically, I can add my SSH key to any server I have access to. With BitBucket, that's not always true.
BitBucket does not allow the same key to be used for two different accounts. Security measure, I'm sure. It does make it difficult to access my company account and my personal account from the same machine.
The workaround is to do the initial download via https, then change the protocol. More specifically....
Setup:Assuming 'WORK' and 'HOME' are two separate BitBucket accounts and you are using a single client (laptop, whatever) to access them both... Decide which one should be less effort -- in this case, I chose WORK.
1. Create an SSH key for WORK
Choose the default /home/username/.ssh/id_rsassh-keygen
2. Copy id_rsa.pub into your BitBucket WORK account
3. Create an SSH key for HOME
Choose /home/username/.ssh/id_personal_rsa or something else obviousssh-keygen
4. Copy id_personal_rsa.pub into your BitBucket HOME account
The Good:For WORK repos, you can simply do the normal
hg clone ssh://email@example.com/WORK/REPO
The Ok, I Guess:For HOME repos, you have to take an extra step.
hg clone https://USERNAME@bitbucket.org/USERNAME/REPO
Then, edit REPO/.hg/hgrc
todefault = hg clone https://USERNAME@bitbucket.org/USERNAME/REPO
default = hg clone ssh://firstname.lastname@example.org/USERNAME/REPO
Then, add this into that file:
ssh = ssh -C -i ~/.ssh/id_personal_rsa.pub -o IdentitiesOnly=yes
Now you should be able to push/pull using SSH.