-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Github with SSH key
Git for Windows comes with a "Git Bash" that gives you good Git functionality over SSH. But what if you want to use Powershell instead of Bash? This guide shows you how to do just that, without needing to re-type your password each time you connect.
This guide uses Github as an example, but the same principals apply for any SSH-accessible Git repo.
This assumes you have installed Scoop, and have a basic knowledge of Git.
Based on this guide from GitHub
First up, install the programs you need:
scoop install git openssh
If you don't already have an SSH key, you can create one like this:
PS> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/you//.ssh/id_rsa): [press enter] Enter passphrase (empty for no passphrase): [type your password] Enter same passphrase again: [and once more] ...
Then add your SSH key to GitHub.
Pshazz includes a plugin for SSH that can save your SSH key password in Windows Credential Manager so you don't need to re-type it every time you push to your Github repo. Install it like this:
scoop install pshazz
And you can set up git client to store your GitHub access token to Windows Credential Manager by:
git config --global credential.helper manager-core
You should see a popup asking for your SSH key password: enter it and check the box to save your password. Back in your Powershell session, you should see an Identity Added
message. Whenever you start a Powershell session from now on, Pshazz will make sure the ssh-agent
is running and load your private key using your saved password.
To make sure everything's working, run:
ssh -T git@github.com
After a warning or two, you should see a message like this:
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.