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

Visual Studio WSL connection Failure #2505

Closed
IkoLogs opened this issue Sep 17, 2017 · 5 comments
Closed

Visual Studio WSL connection Failure #2505

IkoLogs opened this issue Sep 17, 2017 · 5 comments
Labels

Comments

@IkoLogs
Copy link

IkoLogs commented Sep 17, 2017

This bug-tracker is monitored by developers and other technical types. We like detail! So please use this form and tell us, concisely but precisely, what's up. Please fill out ALL THE FIELDS!

WSL connection to visual studio never happy with my login details , if followed this guides below

https://blogs.msdn.microsoft.com/vcblog/2017/02/08/targeting-windows-subsystem-for-linux-from-visual-studio/

https://stackoverflow.com/questions/45465756/visual-studio-2017-cannot-connect-to-wsl-says-username-and-password-are-wrong

https://www.hanselman.com/blog/WritingAndDebuggingLinuxCApplicationsFromVisualStudioUsingTheWindowsSubsystemForLinux.aspx

I follow the instructions:

Host Name = localhost
Port = 22
User name = User name I created for WSL
Authentication Type = Password
Password = Password I created for WSL user name.

with credentials above it doesnt like username password.
i change port number in WSL config file to 2222, then it does not like port number.

I return to port 22, disbale ssh broker on windows , and still no luck

Need help getting WSL to connect to my Vs2017 using latest update .

If you have a feature request, please post to the UserVoice.

Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues. Instead, send dumps/traces to [email protected], referencing the GitHub bug number. Ideally, please configure your machine to capture minidumps, repro the issue, and send the minidump from "C:\Windows\minidump".

Visual studio 2017 will not connect to WSL, complains password and username i setup is wrong
but i gave same credentials i used to setup wsl

  • Strace of the failing command, if applicable: (If <cmd> is failing, then run strace -o strace.txt -ff <cmd>, and post the strace.txt output here)

See our contributing instructions for assistance.

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 17, 2017

I return to port 22, disbale ssh broker on windows , and still no luck

Exit all WSL instances and do a [edit: args] netstat /a /n from the cmd.exe prompt. Look to see if you have anything listening on port 22; likely you will. I hit this regularly as well because Windows seems to like firing up Device Discovery on port 22 even when you have it turned off. This is not just "non-obvious" behaviour; it's a Windows bug. The irony is the MSVS for Linux instructions say "Enable Developer Mode", which is exactly what gets us conflicting with Device Discovery in the first place.

To turn Device Discovery off, go to Settings -> Update & Security -> For Developers, and go back to "Windows Store Apps" mode. Check netstat again to make sure device discovery is dead. Now fire up sshd on WSL and you should be good. You can do a quick ssh localhost inside WSL to confirm it is working. You can then go back to Developer Mode and you'll still be good. [Until you're not; so you do the Dev Mode -> Store Mode -> Dev Mode rain dance again.]

Lord knows what devs who want "Device Discovery" and real sshd on port 22 are supposed to do, except use a different non-standard port for real sshd. That's another work-around if you prefer; start WSL sshd on port 2222 and use that port in MSVS. That MSFT grabs non-configurable port 22 for Device Discovery is just rude, but what you gonna do.

Regardless of the problem, it likely isn't a "WSL thing" or a "MSVS for Linux thing". If you can't ssh in from MSVS it is likely you can't ssh in from PuTTY either. Unless you have other configuration problems (possible), but that is less likely given your symptoms.

@IkoLogs
Copy link
Author

IkoLogs commented Sep 20, 2017

Hi

Thanks you very much. Discovery seems to be affecting the results of this test.
But all attempts including those above resulted in same error of my credentials not being accepted to login into WSL from MSVC. Even added the port In question as allowed in windows firewall but no luck.

However further research shows some are having success with insider builds of windows 16xxx and above.

I am quite desperate to be able to use GCC compiler from MSVC with WSL to make that possible.
Reason got a huge template based solution that really needs the help of Concepts TS , and only GCC compiler provides that as far I know.

Quite scary that some are only able to get this to work by reinstalling windows from scratch.

When my insider build download complete I try again.

Thanks for the detailed information above.

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 20, 2017

sshd has worked in WSL since summer of 2016, so it isn't an 16xxx upgrade thing. It is possible you are seeing a twofold problem: one having to do with Discovery and one having to do with general networking VPN&Firewall problems you've read. But highly improbable given your description. You said "resulted in the same error of my credentials". That means something that is listening on port 22 answered the phone, and doesn't like what you have to say. If you were having more general difficulties you'd see access denied trying to connect to the port, or no connection at all; not rejected credentials. Don't go reinstalling Windows just yet; you'll likely end up back in the same place.

In /etc/sshd/sshd_config make sure you have:

ListenAddress 0.0.0.0
UsePrivilageSeparation no
PasswordAuthentication yes

[Not all those may be necessary on recent releases, but that's the secret handshake around here.]

Forget MSVC for now. Start sshd with debugging so you can see what it is doing:

sudo /usr/sbin/sshd -d -p 2222

In another terminal try connecting:

ssh localhost -p 2222

Once you get that working, move on to trying to connect with PuTTY, and then worry about MSVC. Bonne chance.

@IkoLogs
Copy link
Author

IkoLogs commented Sep 20, 2017

Thanks give that a try return with feedback

@IkoLogs
Copy link
Author

IkoLogs commented Sep 20, 2017

That fixed it.

Windows insider update 16288 completed and WSL still failed on Authentication

Since am unix/Linux/bash novice your simple 2 window test above allowed me to play with options in my WSL config and see results quickly

This led me to the config line AllowUsers 'MyUserName'
took out the ' ' around username
AllowUsers MyUserName
and it was fixed

Can now connect from VS, thanks for the help.

great stuff.

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

2 participants