Get Git cli working from Windows 10 Linux subsystem to github.com
Git cli from Windows 10 WSL Ubuntu
Using the git cli and authenticating with a git server like github.com is generally pretty straightforward, but if you’re using Windows 10 WSL Ubuntu then you need to explicitly set up ssh keys. This will be a separate key than what you may be using for your windows 10 git cli for github.com. This is because the WSL Ubuntu you’re running in your windows 10 is its own separate OS than the Windows 10 OS.
Here’s some good documentation generating a new ssh key
- This command generates a new ssh key
$ ssh-keygen -t ed25519 -C "your@email.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/home/userid/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/userid/.ssh/id_ed25519 Your public key has been saved in /home/userid/.ssh/id_ed25519.pub The key fingerprint is: SHA256:RjKzR+igSe9MdrPgO2G2p456r7Ay/rn+/sFese06llA your@email.com The key's randomart image is: +--[ED25519 256]--+ | | | . | | . . = o | | . + odd E | | o = = S. | | *+o.* + | |. ossso.o.. | |oo..+.o o+. | |===OO*.ss.o. | +----[SHA256]-----+
-
passphrase may be left empty, its optional for more security.
- This command adds the key to your ssh agent
$ ssh-add /home/userid/.ssh/id_ed25519 Could not open a connection to your authentication agent.
- if you get a message like above that means you need to start up the ssh-agent app, you may do so with this:
$ ssh-agent /bin/sh
- Now you can add the ssh key
$ ssh-add /home/userid/.ssh/id_ed25519 Identity added: /home/userid/.ssh/id_ed25519 (your@email.com)
-
Once added, take a look at that ssh key pairs public key, it will have the same name as the private key but with a
.pub
file extension$ cat /home/userid/.ssh/id_ed25519.pub
-
Now log into github.com and go to your profile->Settings->SSH and GPG keys->click
New SSH Key
then paste the contents of the .pub file from the previous step - now when you try to talk to github.com with the git cli in ubuntu in windows cli it should work fine.