Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicklegan/setup-git-and-ssh-on-windows-with-github
Install and configure Git, PuTTY and SSH keys on Windows with GitHub
https://github.com/nicklegan/setup-git-and-ssh-on-windows-with-github
git-for-windows putty ssh ssh-key
Last synced: 21 days ago
JSON representation
Install and configure Git, PuTTY and SSH keys on Windows with GitHub
- Host: GitHub
- URL: https://github.com/nicklegan/setup-git-and-ssh-on-windows-with-github
- Owner: nicklegan
- Created: 2021-04-01T18:54:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-02T16:21:03.000Z (almost 4 years ago)
- Last Synced: 2024-10-04T11:41:23.756Z (3 months ago)
- Topics: git-for-windows, putty, ssh, ssh-key
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](#Git-for-Windows)
- [PuTTY](#PuTTY)
* [PuTTY Key Generator (puttygen.exe)](#PuTTY-Key-Generator-(puttygen.exe))
* [PuTTY Authentication Agent (pageant.exe)](#PuTTY-Authentication-Agent-(pageant.exe))
* [Plink - Command Line Connection Tool (plink.exe)](#Plink---Command-Line-Connection-Tool-(plink.exe))
- [Git global config](#Git-global-config)
- [Testing](#Testing)
- [Resources](#Resources)## Git for Windows
- Download and install the latest [Git for Windows](https://gitforwindows.org/)
(skipped steps :point_down: can be treated having default values)
1. Select Components (default)
2. Adjusting the default branch name for new repositories (main branch)
3. Adjusting your PATH environment
- Git from the command line and also from 3rd party software
4. Choosing HTTPS transport backend
5. Configuring the line ending conversions
6. Use MinTTY (the default terminal of MSYS2)
7. Choose the default behavior of `git pull`
8. Choose a credential helper
9. Configuring extra options
10. Configuring experimental options
11. Completing the Git Setup Wizard
- yes, restart the computer now
## PuTTY
1. Download and install the latest [PuTTY MSI Package installer](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) for Windows
:bulb: This package installer will also contain and automatically installs the required `plink.exe`, `pageant.exe` and `puttygen.exe` binaries required :point_down:.
2. Destination folder
3. Product Features
4. 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)
5. Run `puttygen.exe` either from the Start menu or the direct locaation at `C:\Program Files\PuTTY\puttygen.exe`
6. 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.
7. Enter your email address in the `Key comment` box.
8. Provide a passphrase, and repeat it in the subsequent textbox.
9. 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.
10. 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 :point_up:).
11. Open your browser and navigate to github.com and add a new [SSH key](https://github.com/settings/ssh/new) 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`.
:bulb: 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](https://docs.github.com/en/github/authenticating-to-github/authorizing-an-ssh-key-for-use-with-saml-single-sign-on) for the specific GitHub organizations.
### PuTTY Authentication Agent (pageant.exe)
12. 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```
13. At the new Pageant shortcut startup location, right-click the Pageant shortcut and select `Properties` from the context menu.
14. 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```
15. Double click the Pageant shortcut file which starts Pageant and enter your private key passphrase.
16. 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.
17. From the Pageant menu select `View Keys` to verify that your private key is loaded.
## Plink - Command Line Connection Tool (plink.exe)
To automatically let Putty establish a connection for Git over SSH we have to configure Plink.
18. 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```
19. 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.
## Git global config
Setup your [Git username](https://docs.github.com/en/github/getting-started-with-github/setting-your-username-in-git#setting-your-git-username-for-every-repository-on-your-computer) and [commit email address](https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address#setting-your-commit-email-address-in-git) 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 [email protected]`## Testing
1. Open a Windows command prompt and test your connection and authentication using the following command: `plink.exe -v [email protected]` the result should look like :point_down:.
2. Now try cloning a private repository using Git over SSH, when successful the expected output should look like the image :point_down: and you will be automatically authenticated.
## Resources
- https://vladmihalcea.com/tutorials/git/windows-git-ssh-authentication-to-github/
- https://serverfault.com/questions/194567/how-do-i-tell-git-for-windows-where-to-find-my-private-rsa-key/850156#850156