Using TortoiseHg with Bitbucket and SSH.

Update: Atlassian left a comment saying that they have updated their help with a lot more information. So check that out for more details than the below.

This is more of a reference for myself as I forgot my SSH key passphrase and needed to generate a new public/private key pair. The most troublesome part is step 6 as Bitbucket will not accept your PuTTYgen public key, thanks to Ciaro for the copy and paste solution.

  1. Create an account at bitbucket.org.
  2. Install TortoiseHg (A Mercurial GUI).
  3. Install PuTTYgen.
  4. Using PuTTYgen to create a new key pair with a passphrase (don't forget it:)
  5. Save the public (yourkey) and private key (yourkey.ppk), you would normally save them in a hidden .ssh folder in your user directory e.g. C:\Users\YourUsername\.ssh\.
  6. Open the public key (yourkey) you generated using PuTTYgen, it should look similar to the below:
    ---- BEGIN SSH2 PUBLIC KEY ----
    Comment: ""
    AAAAB3NzaC1yc2EAAAABJQAAAIBjudcRBfSSybUGzpinB9t31G9ZoHBPdOGTUTEs
    lyP4pLZrGZtIqtMfqr+L7G4FRathjBjTsl5MTUOgdC2Jvd9nDS949L+icjVTeQ9Q
    xf+VQL9E08o38bxK7BZJDsHoguO3llY4lfD7rF2yC3T7jc7PhW3yHgY9RU2CqY3A
    j6FkFw==
     ---- END SSH2 PUBLIC KEY ----
    
    You need to create a new compatible file for Bitbucket (yourkey.pub) which contains just one line (careful with spaces - you need one before and after the key part) consisting of: SSH key type, key part, and your user name. Example:
    ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBjudcRBfSSybUGzpinB9t31G9ZoHBPdOGTUTEslyP4pLZrGZtIqtMfqr+L7G4FRathjBjTsl5MTUOgdC2Jvd9nDS949L+icjVTeQ9Qxf+VQL9E08o38bxK7BZJDsHoguO3llY4lfD7rF2yC3T7jc7PhW3yHgY9RU2CqY3Aj6FkFw== This email address is being protected from spambots. You need JavaScript enabled to view it.
    
  7. Open your new public key file (yourkey.pub), copy the contents and then paste the key into your Bitbucket account.
  8. In your TortoiseHg program files directory run Pageant.exe and add (right click on its tray icon) your private key (yourkey.ppk).
  9. Open your mercurial.ini file (On Windows 7 it is found in C:\Users\YourUsername\), you need to add/edit an SSH line under the UI section like below:
    # Generated by TortoiseHg setting dialog
    [ui]
    username = yourUserName <This email address is being protected from spambots. You need JavaScript enabled to view it.>
    ssh = "C:\Program Files (x86)\TortoiseHg\TortoisePlink.exe" -ssh -2 -i C:\Users\YourUsername\.ssh\yourkey.ppk
    editor = notepad
    
  10. Clone your repository: ssh://This email address is being protected from spambots. You need JavaScript enabled to view it./YourUserName/YourRepositoryName
  11. Hopefully everything worked.