Install and configure Git, PuTTY and SSH keys on Windows with GitHub
- Download and install the latest Git for Windows
(skipped steps π can be treated having default values)
- Select Components (default)
- Adjusting the default branch name for new repositories (main branch)
- Adjusting your PATH environment
- Git from the command line and also from 3rd party software
- Choosing HTTPS transport backend
- Configuring the line ending conversions
- Use MinTTY (the default terminal of MSYS2)
- Choose the default behavior of
git pull
- Choose a credential helper
- Configuring extra options
- Configuring experimental options
- Completing the Git Setup Wizard
- yes, restart the computer now
- 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 π.
- Destination folder
- Product Features
- 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\
- Run
puttygen.exe
either from the Start menu or the direct locaation atC:\Program Files\PuTTY\puttygen.exe
-
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. -
Enter your email address in the
Key comment
box. -
Provide a passphrase, and repeat it in the subsequent textbox.
-
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. -
In
puttygen.exe
copy the generated Public key visible underPublic key for pasting into OpenSSH authorized keys file
to your Windows clipboard (see image βοΈ). -
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
.
π‘ 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.
- 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
- At the new Pageant shortcut startup location, right-click the Pageant shortcut and select
Properties
from the context menu.
- 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
- Double click the Pageant shortcut file which starts Pageant and enter your private key passphrase.
- 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.
- From the Pageant menu select
View Keys
to verify that your private key is loaded.
To automatically let Putty establish a connection for Git over SSH we have to configure Plink.
- 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
- 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 enabledGIT_SSH
variable.
Setup your Git username and commit email address for your system. Open a command prompt and enter the below lines, adding your personal info.
git config --global user.name "First-name Last-name"
git config --global user.email your@email-address.com
- 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 π.
- 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.