Does anybody know how to get github ssh to work CORRECTLY on WSL (Windows Subsystem for Linux) in December of 2019

Issue

I need to run windows for video editing but I also do some coding. Linex is a beast and I would love to be able to use WSL on my windows computer and be able to do ssh from WSL. I am trying to start a thread where people can go to and follow the steps for WSL and Github ssh on windows. Can someone help me figure out what I am doing wrong so others can use WSL and Github as well?

My steps:

  1. Reset windows
  2. go to this site and install WSL https://learn.microsoft.com/en-us/windows/wsl/install-win10
    I chose Ubuntu 18.04 LTS: https://www.microsoft.com/en-us/p/ubuntu-1804-lts/9n9tngvndl3q?rtc=1&activetab=pivot:overviewtab
  3. set up and upgrade Ubuntu:
    sudo apt update && sudo apt upgrade
  4. Installed VS Code using this website: https://code.visualstudio.com/docs/remote/wsl
  5. INstalled the Remote Development Pack: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
  6. Set up gitbash on windows using defaults
  7. Set up git ssh with this site:https://help.github.com/en/github/authenticating-to-github/checking-for-existing-ssh-keys
  8. Did a git clone made changes and pushed to master just to make sure everything work, It does.
  9. added a .gitattributes file to repo
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

(is there a way to make this automatic?)

  1. Then I ran this command because it suggested it on the site…
git config --global core.autocrlf input
  1. Git still works

  2. dis these steps to share credentials

Configure the credential manager on Windows by running the following in a Windows command prompt or PowerShell:

 git config --global credential.helper wincred
Configure WSL to use the same credential helper, but running the following in a WSL terminal:

 git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"
  1. Ran git push from wsl and goterror:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.      

Please make sure you have the correct access rights
and the repository exists.

Git push works on windows side

Solution

Eureka I got it!!

After all the steps above go into your windows terminal and run:

$ ssh -T [email protected]

You should get:

You've successfully authenticated, but GitHub does not provide shell access.

Then on ubuntu enter:

$ cd
$ cd .ssh 
$ code .

This will open up your ubuntu .ssh folder in VS code.

Then open power shell and run:

> cd .ssh
> code .

This will open up your windows .ssh folder in VS code.

Then you can drag and drop your windows fils to ubuntu through vs code.

Now go back to your WSL terminal and run:

$ ssh -T [email protected]

If you get:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0666 for '/home/andre/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/andre/.ssh/id_rsa": bad permissions
[email protected]: Permission denied (publickey).

Then run:

$ sudo chmod 600 ~/.ssh/id_rsa
$ sudo chmod 600 ~/.ssh/id_rsa.pub

Now when you run:

$ ssh -T [email protected]

You should get:

You've successfully authenticated, but GitHub does not provide shell access.

Answered By – André Jarboe II

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published