Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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://docs.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

like image 591
André Jarboe II Avatar asked Dec 20 '19 16:12

André Jarboe II


People also ask

Does GitHub desktop work WSL?

Git can be installed on Windows AND on WSL The root of your file system / is the mount point of your root partition, or folder, in the case of WSL. Not everything under / is the same drive. For example, on my laptop, I've installed two version of Ubuntu (20.04 and 18.04), as well as Debian.


2 Answers

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.
like image 121
André Jarboe II Avatar answered Sep 20 '22 02:09

André Jarboe II


The steps would be like,

  1. Get SSH working on your Windows machine. For this please follow the official guide.
  2. Copy the SSH files from Windows to WSL.

For this you can try with the following commands,

cp -r /mnt/c/Users/<username>/.ssh ~/.ssh

If the directory copy doesn't work, then you can try to copy single file as well.

cp -r /mnt/c/Users/<username>/.ssh/<file-name> ~/.ssh
  1. Fix the permission

If it gives error for permission, then change the permission to 600 for the file for which it shows error.

chmod 600 ~/.ssh/<file-name>
  1. Finally run the following

Last step should be the following command,

ssh -T [email protected]

You should be good to go now.

like image 33
gprathour Avatar answered Sep 23 '22 02:09

gprathour