Skip to content

Install and configure Git, PuTTY and SSH keys on Windows with GitHub

Notifications You must be signed in to change notification settings

nicklegan/setup-git-and-ssh-on-windows-with-github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

Setup Git and SSH on Windows with GitHub

Install and configure Git, PuTTY and SSH keys on Windows with GitHub

Setup overview

Git for Windows

(skipped steps πŸ‘‡ can be treated having default values)

  1. Select Components (default)

Screenshot 2021-04-01 at 12 51 37

  1. Adjusting the default branch name for new repositories (main branch)

Screenshot 2021-04-01 at 12 56 42

  1. Adjusting your PATH environment
  • Git from the command line and also from 3rd party software

Screenshot 2021-04-01 at 13 07 10

  1. Choosing HTTPS transport backend

Screenshot 2021-04-01 at 13 14 49

  1. Configuring the line ending conversions

Screenshot 2021-04-01 at 13 16 58

  1. Use MinTTY (the default terminal of MSYS2)

Screenshot 2021-04-01 at 13 20 12

  1. Choose the default behavior of git pull

Screenshot 2021-04-01 at 13 22 49

  1. Choose a credential helper

Screenshot 2021-04-01 at 13 24 36

  1. Configuring extra options

Screenshot 2021-04-01 at 13 25 49

  1. Configuring experimental options

Screenshot 2021-04-01 at 13 26 51

  1. Completing the Git Setup Wizard
  • yes, restart the computer now

Screenshot 2021-04-01 at 13 28 26

PuTTY

  1. Download and install the latest PuTTY MSI Package installer for Windows

πŸ’‘ This package installer will also contain and automatically installs the required plink.exe, pageant.exe and puttygen.exe binaries required πŸ‘‡.

  1. Destination folder

Screenshot 2021-04-01 at 13 50 22

  1. Product Features

Screenshot 2021-04-01 at 13 55 24

  1. After the installation of PuTTY has finished, create a .ssh folder in your logged in user folder: C:\Users\yourusername\.ssh\ or the equivalent %USERPROFILE%\.ssh\

PuTTY Key Generator (puttygen.exe)

  1. Run puttygen.exe either from the Start menu or the direct locaation at C:\Program Files\PuTTY\puttygen.exe

Screenshot 2021-04-01 at 15 18 17

  1. Click Generate, wiggle the mouse around in the top part of the window until the progress bar is full, as the program asks you to do.

  2. Enter your email address in the Key comment box.

  3. Provide a passphrase, and repeat it in the subsequent textbox.

  4. Click Save private key. Save the private key in the %USERPROFILE%\.ssh\ directory created earlier. Give the private key a personal name so it can be easily identified. This file should have a .ppk extension.

  5. In puttygen.exe copy the generated Public key visible under Public key for pasting into OpenSSH authorized keys file to your Windows clipboard (see image ☝️).

  6. Open your browser and navigate to github.com and add a new SSH key in your account settings. Choose a key title (e.g. your email address or computer name) and paste the public SSH key data from clipboard before pressing Add SSH key.

Screenshot 2021-04-01 at 15 33 51

Screenshot 2021-04-01 at 15 34 38

πŸ’‘ If you have and need command line access to GitHub Single sign-on organizations make sure you authorize your SSH key by activating Enable SSO for the specific GitHub organizations.

PuTTY Authentication Agent (pageant.exe)

  1. To automatically run pageant.exe and the loaded private key at startup copy the Pageant shortcut from:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PuTTY (64-bit)

%ProgramData%\Microsoft\Windows\Start Menu\Programs\PuTTY (64-bit)

to

C:\Users\your-username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

%AppData%\Microsoft\Windows\Start Menu\Programs\Startup

  1. At the new Pageant shortcut startup location, right-click the Pageant shortcut and select Properties from the context menu.

Screenshot 2021-04-01 at 17 44 24

  1. At the Pageant Properties append the path to your private key in the Target field and press Apply:

"C:\Program Files\PuTTY\pageant.exe" C:\Users\your-user-name\.ssh\your-private-key.ppk

  1. Double click the Pageant shortcut file which starts Pageant and enter your private key passphrase.

Screenshot 2021-04-01 at 17 51 31

  1. On the right side of the Windows taskbar Pageant should now be running, if it was already running press Exit and double click the newly created startup shortcut again.

Screenshot 2021-04-01 at 18 13 17

  1. From the Pageant menu select View Keys to verify that your private key is loaded.

Screenshot 2021-04-01 at 18 21 24

Plink - Command Line Connection Tool (plink.exe)

To automatically let Putty establish a connection for Git over SSH we have to configure Plink.

  1. Nagivate to Start menu (right-click) -> System -> Advanced system settings -> Environment Variables. Add a new System Variable with the below entries:

Variable name: GIT_SSH

Variable value: C:\Program Files\PuTTY\plink.exe

Screenshot 2021-04-01 at 19 11 38

  1. To verify if the environment variable is loaded run Git Bash from the Start menu (or via its absolute path: C:\Program Files\Git\git-bash.exe) and enter the following command: env | grep -i ssh which should return the enabled GIT_SSH variable.

Screenshot 2021-04-01 at 19 29 05

Git global config

Setup your Git username and commit email address for your system. Open a command prompt and enter the below lines, adding your personal info.

  1. git config --global user.name "First-name Last-name"
  2. git config --global user.email your@email-address.com

Testing

  1. Open a Windows command prompt and test your connection and authentication using the following command: plink.exe -v git@github.com the result should look like πŸ‘‡.

Screenshot 2021-04-01 at 19 40 03

  1. Now try cloning a private repository using Git over SSH, when successful the expected output should look like the image πŸ‘‡ and you will be automatically authenticated.

Screenshot 2021-04-01 at 19 51 16

Screenshot 2021-04-01 at 19 54 22

Resources

About

Install and configure Git, PuTTY and SSH keys on Windows with GitHub

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published