Skip to content

[wsl2] can't use ssh #4208

Closed
Closed

Description

@transtone

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.

Activity

  1. therealkenc commented on Jun 22, 2019

    @therealkenc

    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.]

  2. transtone commented on Jun 22, 2019

    @transtone
    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.

  3. therealkenc commented on Jun 22, 2019

    @therealkenc

    because of this annoying bug

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

  4. transtone commented on Jun 23, 2019

    @transtone
    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.

  5. therealkenc commented on Jun 23, 2019

    @therealkenc

    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

  6. transtone commented on Jun 24, 2019

    @transtone
    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.

  7. CamberLoid commented on May 21, 2020

    @CamberLoid

    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.

  8. KexyBiscuit commented on May 21, 2020

    @KexyBiscuit

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

  9. pdelaney-802 commented on Jun 18, 2020

    @pdelaney-802

    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.

  10. thedevelopnik commented on Jun 19, 2020

    @thedevelopnik

    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.

  11. therealkenc commented on Jun 19, 2020

    @therealkenc

    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).

  12. hiyyg commented on Sep 5, 2020

    @hiyyg

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

  13. robertzhangwenjie commented on Sep 12, 2020

    @robertzhangwenjie

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

  14. acmuller commented on Oct 4, 2020

    @acmuller

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

  15. behnam-io commented on Jul 3, 2021

    @behnam-io

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

  16. shimbalama commented on Sep 14, 2021

    @shimbalama

    same

  17. AbdelrahmanElsaidElsawy commented on Nov 23, 2021

    @AbdelrahmanElsaidElsawy

    Hi all, i've found the solution here
    [(https://github.community/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions