Ssh clone works in Git bash but not in WSL2 git #22218
-
Could someone help me figure out how to get git clone over ssh working in Windows Subsystem for Linux (WSL2) with Ubuntu version 20.04.1 LTS? Testing the ssh connection or attempting to clone a repo over ssh both fail with the error message “Received disconnect from 192.30.255.112 port 22:11: Bye Bye” and “fatal: Could not read from remote repository.” Here are the commands I’m using:
Note: space between git and @ added so I can submit this post. Performing the clone over HTTPS works:
I run these commands to setup SSH from within an Ubuntu bash terminal:
I realize there are some extra steps there. I use pkill to stop the ssh-agent process and make sure that’s not causing problems, same with using “ssh-add -D” to make sure there are no certificates. I copy the content of ~/.ssh/id_rsa.pub and add the corresponding SSH key in my GitHub account. I try the testing the ssh connection and cloning a repo after everything is setup with no luck. None of this works from Ubuntu under WSL2, but to cross-reference this, I removed ~/.ssh and killed the ssh-agent and tried everything from scratch using Git Bash - it works from there. I tried checking which version of git is installed in Ubuntu. It was an old version, so I upgraded it so now git.exe from the Git Bash Windows installation and the Ubuntu git are the same version. I tried using the version of git that comes with Git Bash under Ubuntu with the command:
That works. Basically, I can get everything working under Git Bash, but not Ubuntu and I’m not sure why. I even tried copying the .ssh directory from my home directory in Windows to my home directory in Ubuntu. I tried uninstalling/reinstalling Git Bash and trying different options for the credential helper, including using the Git Credential Manager Core, the Git Credential Manager, and none. None of that made a difference, tho I found it interesting that running ‘git clone’ under Ubuntu would trigger a popup menu from Git Credential Manager Core, which doesn’t work and does a fail over to basic authentication at the command prompt. I have tried all of this using an Ubuntu Bash Shell from the Windows Start menu, an Ubuntu Bash Shell from Windows Terminal, and an Ubuntu Bash Shell “Terminal” from Visual Code. Another thing I tried was cross-referencing this with using a phrase and not using a phrase when generating the keys. Finally… I notice that when I try this from Git Bash, I get prompted to create a new entry in known_hosts. This does not happen when I try with Git in Ubuntu. I tried just copying the known_hosts file to ~/.ssh but that didn’t seem to help. I’m not sure if this information is being cached anywhere, but GitHub seems respond pretty quickly every time I delete and recreate the keys from within Git Bash. Here are the documents I’ve been trying to follow:
Sorry if this is too much detail, but I really do appreciate your help. -Ed |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
I just thought of something else to add that I’ve done while troubleshooting this… I went into the Windows Credential Manager > Windows Credentials > Generic Credentials… and made sure to remove anything associated with GitHub. |
Beta Was this translation helpful? Give feedback.
-
I had another idea to cross-reference this using Debian instead of Ubuntu under Windows 10 (WSL2)… Everything is working within Debian. Any ideas on why Ubuntu isn’t working? -Ed |
Beta Was this translation helpful? Give feedback.
-
I decided this must be something specific to the copy of Ubuntu 20.04 LTS available in the Microsoft App store for installation on Windows 10 because I don’t run into any of these problems using the 18.04 LTS version of Ubuntu available from the Microsoft App store or the Debian installation. Steps to reproduce are pretty straight forward…
This works with Ubuntu 18.04 LTS but not with 20.04 LTS. This all works for Ubuntu 18.04 LTS but not for 20.04 LTS. |
Beta Was this translation helpful? Give feedback.
-
I used SSH in 20.04 LTS 18.04 LTS and 20.04.1 LTS. It all works in good way. I can’t understand. One more thing whats this
bluesherpa:
Now look here. You added a space between
|
Beta Was this translation helpful? Give feedback.
-
bluesherpa:
WSL is nested virtualisation There is no need for these. both don’t share same place for credential. One is Linux and other is windows. They are far beyond. |
Beta Was this translation helpful? Give feedback.
-
Hi DarkRaspberry, Regarding the spaces, I mentioned in the first post that I had to add those in order to submit the post. I didn’t have the spaces while testing and trying to get this to work. My account is still considered New since I haven’t posted much here, so there was I was limited in the number of links I could include and had to use formatting with spaces as a work around solution. What you’re saying about the Windows Credentials makes sense. One of the help articles I referenced includes those steps. Apparently the Git Credential Manager is being used in some configurations. I agree it shouldn’t be necessary, but mentioned it in case it’s part of the problem. It’s great to hear it worked for you on on 20.04 LTS. Did you use the steps I outlined? I am running into the problem with a new installation of 20.04 LTS and the steps I provided. |
Beta Was this translation helpful? Give feedback.
-
Hi darkRaspberry! I did more testing today. I have no idea what’s causing the issue, but I created a bash script and a set of key files to make sure I am testing everything consistently in each environment. Everything works in fresh installations of Ubuntu 18.04 LTS and Debian. The problem shows up in a fresh installation of Ubuntu 20.04 LTS. The problem also shows up if I take an instance of Ubuntu 18.04 LTS and upgrade it to Ubuntu 20.04 LTS. I noticed the upgrade results in going from OpenSSH 7.6p1 to OpenSSH 8.2p1 and from OpenSSL 1.0.2n to OpenSSL 1.1.1f, so I did an experiment of doing a fresh installation of Ubuntu 18.04 LTS and only upgrading OpenSSH and OpenSSL. The problem did not show up. That convinces me the problem has something to do with Ubuntu 20.04 LTS, but I’m not sure what it is, especially since everything works on your copy of it. -Ed |
Beta Was this translation helpful? Give feedback.
-
Marking this closed. Another friend confirmed that they run into the same problem from their computer when doing a fresh installation of Ubuntu 20.04 LTS. |
Beta Was this translation helpful? Give feedback.
I used SSH in 20.04 LTS 18.04 LTS and 20.04.1 LTS. It all works in good way. I can’t understand.
One more thing whats this
./
thing.I guess this command is enough for a clone using ssh.
git clone git@github.com:username/repo.git
Now look here. You added a space between
git
and@github.com
which is not required. and last./
this is also not required.Can you use this and confirm whats showing in the WSL with a screenshot
git clone git@github.com:bluesherpa/array_sort.git