Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wsl2] can't use ssh #4208

Closed
transtone opened this issue Jun 21, 2019 · 17 comments
Closed

[wsl2] can't use ssh #4208

transtone opened this issue Jun 21, 2019 · 17 comments
Labels

Comments

@transtone
Copy link

in wsl2 when I use ssh to login a remote server, the connection closed immediately.
I change the distro to v1, the connection can establish.

when use git (with ssh-key) to push file to github, it fail too. it says:

Received disconnect from 13.250.177.223 port 22:11: Bye Bye
Disconnected from 13.250.177.223 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
@therealkenc
Copy link
Collaborator

is also problematic because it brings down the whole ssh key exchange (and by extension git) edifice.

#4208

Might be #4199 related. But probably (?) not. There isn't enough in the OP to tell definitively. You can get that fatal for all manner of reasons. Above you are on the client side. Github doesn't care if your local IP address changed. On the other hand, you'd care a lot if Github's IP address kept changing and you couldn't do a DNS lookup on github.com.

Only way to tell conclusively would be set up your keys again and see if that fixes the problem. Which isn't really a WSL question, ever shifting client IP address or not. Not to diminish the other issue. [N.b. I retired from diving ssh problems a couple of years ago because ssh does work as advertised on both WSL1 and WSL2.]

@transtone
Copy link
Author

because of this annoying bug, I decide not use the ssh client of wsl distro, but use OpenSSH in C:\WINDOWS\System32\OpenSSH. this do solve my problem.

@therealkenc
Copy link
Collaborator

because of this annoying bug

Well let's be clear - no. No bug has been identified here. But happy to hear you are unblocked.

@transtone
Copy link
Author

not a bug? Is this a feature?
if this is a feature, why saying this:

In the initial builds of the WSL 2 preview, you will need to access any Linux server from Windows using the IP address of your Linux distro, and any Windows server from Linux using the IP address of your host machine. This is something that is temporary, and very high on our priority list to fix.

@therealkenc
Copy link
Collaborator

therealkenc commented Jun 23, 2019

if this is a feature, why saying this:

Because that paragraph has nothing to do with your OP. Git push to github works in WSL2 regardless of whether "you will need to access any Linux server from Windows using the IP address of your Linux distro".

No bug has been identified here

The word "identified" is important here. That you cannot push to Github does not identify a bug. Indeed, the scope for bugs has shrunken considerably in WSL2 (vs. WSL1) because you'd have to conclude you found something new and novel wrong with either (a) Hyper-V or (b) the Linux kernel.

The reason for your "fatal: Could not read from remote repository" is, to be clear, neither of those things. Whatever the reason may be. And so the obv isn't lost: git push WSL2 to github works. That you've decided to use Windows OpenSSH instead, for whatever reasons, is fine also; that works too.
The cap below is superfluous. If "[wsl2] can't use ssh" were a bug, you'd know from the screeching.

image

@transtone
Copy link
Author

Thank you for let me know how to identify a bug in wsl.
It must be something wrong with the network that makes ssh can't connect remote server, but I don't have the time to solve it. So I open a issue to let you guys know someone trouble about this, and how to avoid this.
I'll try to solve this after wsl2 stable release, if it has the same problem.

@CamberLoid
Copy link

CamberLoid commented May 21, 2020

Encountered the same issue at WSL2, but after digging further I have a workaround here.
Try to explicitly specify ciphers at /etc/ssh/ssh_config, or run ssh -oCiphers=your_ciphers username@domain. It works for me. NEED TO KEEP THE CIPHER STRING SHORT

Update: I looked up the journals of ssh.service on the other side and got the following message:
error: kex_input_kexinit: discard proposal: string is too large [preauth]
It seems to be a issue of OpenSSH Client or the network part of Linux kernel.(TBH, I don't know how it works, so it might be wrong)

Update: New issue opened. For details see #5244.

Now I know that the issue should be blamed to the too-large preauth string, and explicitly config ciphers might be a workaround.

@KexyBiscuit
Copy link

@CamberLoid Open a new issue might help since this one has been closed for a long time.

@pdelaney-802
Copy link

I just upgraded to WSL2 along with latest Windows 10, 2020 and I cannot ssh to any of our servers now. I have to go to the cmd or powershell it's a bummer. I was excited about WSL2.

@thedevelopnik
Copy link

thedevelopnik commented Jun 19, 2020

I have to add ssh-add ~/.ssh/<name_of_private_key_file> 2> /dev/null to my .zshrc file for it to work. It seems like every session the keys have to be added again. That's the bug to me, I would expect to only have to do that once ever.

@therealkenc
Copy link
Collaborator

I have to add ssh-add ~/.ssh/<name_of_private_key_file> 2> /dev/null to my .zshrc file for it to work

That was mentioned in message with open issue landing zones #4711 #4199 #4210 (depending on one's disposition).

@hiyyg
Copy link

hiyyg commented Sep 5, 2020

I can not use ssh in wsl2. I have to change it back to wsl 1.

@robertzhangwenjie
Copy link

I also encountered this issue in wsl2, its a annoying bug.

@acmuller
Copy link

acmuller commented Oct 4, 2020

Just installed WSL2, and I also can't SSH to any of my servers. Rolling back to WSL1

@behnam-io
Copy link

I'm also facing this issue. Any fix since then?

@shimbalama
Copy link

same

@AbdelrahmanElsaidElsawy

Hi all, i've found the solution here
[(https://github.saobby.my.eu.orgmunity/t/having-an-issue-pull-and-push-in-github/13198/2)]

  • create a file called config in folder ~/.ssh
    cd ~/.ssh
    nano config
  • paste the following
    Host github.com KexAlgorithms=ecdh-sha2-nistp521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests