Skip to content

Instantly share code, notes, and snippets.

@nardan
Last active July 2, 2019 09:30
Show Gist options
  • Save nardan/e78821247e69b9cf2f98e2061ef1735d to your computer and use it in GitHub Desktop.
Save nardan/e78821247e69b9cf2f98e2061ef1735d to your computer and use it in GitHub Desktop.
Setting up SSH for Git & Mercurial

SSH GitHub & Bitbucket

Key Generation

Check for existence

open Git Bash

$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

If you have one skip to Add

Generate

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Add

$ eval $(ssh-agent -s)
> Agent pid 59566

$ ssh-add ~/.ssh/id_rsa

Update Settings

you will need the contents of C:\Users\<USERNAME>.ssh\id_rsa

Git

Already sorted 😊👍

Mercurial

Open PuTTY Key Generator (Start > PuttyGen) either Generate or Conversions (my preference)

Conversions > import key > C:\Users\<USERNAME>\.ssh\id_rsa Note: If you don't see file extensions two file will appear to have the same name. The first (looks like a text file) is the one you want.

  • Save public key Bitbucket.pub.ppk Note .pub. in the file name for the public key.
  • Save private key Bitbucket.ppk

Edit C:\Users\<USERNAME>\mercural.ini and add ssh = ssh -C under [ui]

[ui]
# name and email (local to this repository, optional), e.g.
username = Alex McTest <AlexMcTest@some-domain.com>
ssh = ssh -C

Tortoise HG

In Tortoise HG check repos start with ssh://hg@ Open the repo View > Syncronise (Alt+4)

Pageant Shortcut

If you're fed up with typing in password every time 😕

Create a shortcut in C:\Users\<USERNAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Target

If you create a shortcut in windows Right Click > New > Shortcut you will need to point to the exe ("C:\Program Files (x86)\PuTTY\pageant.exe") and then Right Click > Properties to edit the details.

If you have PuTTY installed.

"C:\Program Files (x86)\PuTTY\pageant.exe" Bitbucket.ppk

or if you don't have PuTTY installed but do have TortoiseGit

"C:\Program Files\TortoiseGit\bin\pageant.exe" Bitbucket.ppk
Start In
C:\Users\<USERNAME>\.ssh

SourceTree

Set up SSH with Sourcetree on Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment