0

I'm trying to ssh from my LAN devices (phone, laptop and even the same computer) into bash.exe following Microsoft's guide on changing the default shell for OpenSSH to bash.exe. Bash in this context should start up "wsl -d YOURDEFAULTDISTRO", which it does if I run it in my local computer. However when I ssh into it, I get:

??? ????? ?????? ? ???????? ??? ?????? ??? ?? ???????
Connection to <my_ip> closed.

I can ssh into powershell normally, no problems there. My Windows are setup in the Greek language, maybe that could be why I'm getting back question marks?

Ramhound
  • 42,708
AxillV
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 05 '23 at 10:24
  • Welcome to Super User! Can you add the output of wsl --version to your question (if it just outputs the help, that is useful info as well) - Thanks! – NotTheDr01ds Apr 07 '23 at 19:29

2 Answers2

0

You will find a better tutorial in the blog
THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine.

This blog post uses Windows' OpenSSH and authenticates with Windows and then runs WSL2. WSL2 starts up, uses bash, and Windows handles the TCP traffic.

To summarize the article :

  • Enable the OpenSSH Server in Windows by in an Admin PowerShell :

    Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
    

    You may verify that it worked using :

    Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
    
  • To set the default shell :

    New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force
    
harrymc
  • 480,290
  • That's exactly what I followed actually and I get the error I mentioned in my original post. – AxillV Apr 05 '23 at 11:36
  • Your article doesn't enable OpenSSH.Server. Do the verification in the first point to see if it's enabled. – harrymc Apr 05 '23 at 11:38
  • It is enabled, at this point I've done enough setup that I'm even able to ssh from my laptop running ubuntu, into my windows machine and then ssh once again into wsl, but trying to change the default shell to bash and trying to ssh from my laptop to my windows machine produces the above error. Also trying to ssh with wsl at the end of the commands produces the same result, and it seems to be that the character match 1-1 (still unreadable question marks though) – AxillV Apr 05 '23 at 11:50
  • OK, so this is not the problem. The question marks are probably caused by your language, but we really need this error message. Try to see if you can find it in the Event Viewer. What exact value did you use for DefaultShell? – harrymc Apr 05 '23 at 11:59
  • I tried checking the auth.log file in my laptop but whenever I ssh'd there wasn't any new log so it should be somewhere else, could you help with locating it? I followed the guide listed above, "New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force", if I open bash from my computer it boots into Ubuntu as expected. – AxillV Apr 05 '23 at 12:07
  • These errors are now in the Event Viewer, see Logging Facilities. You will find them in Applications and Services Logs > OpenSSH > Operational. – harrymc Apr 05 '23 at 12:12
  • Yep I just got to finding that out myself, whenever I ssh there's 3 log messages, there's the message that the public key got accepted, then sshd: Received disconnect from ip:port: disconnected by user and finally sshd: Disconnected from ip:port, all within the timeframe of a single second. – AxillV Apr 05 '23 at 12:15
  • That link also shows how to turn on debugging. – harrymc Apr 05 '23 at 12:18
  • Ok fixed it, I'm not seeing any error message, I think all I am seeing is just the key being accepted, and then binding the ports and nothing else. Would there be an easy way for me to give you a copy of the logs? I'll have to run so I'll get back to you in a couple of hours. – AxillV Apr 05 '23 at 12:27
-2

I met the same problem. I do as this link and set New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\WSL\wsl.exe" -PropertyType String -Force instead, then everything works fine. Hope it's useful to you!