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

Using ssh.exe from WSL does not work properly #990

Closed
StefanScherer opened this issue Dec 14, 2017 · 13 comments
Closed

Using ssh.exe from WSL does not work properly #990

StefanScherer opened this issue Dec 14, 2017 · 13 comments
Assignees

Comments

@StefanScherer
Copy link

StefanScherer commented Dec 14, 2017

Please answer the following

If it is a terminal issue then please go through wiki
https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

"OpenSSH for Windows" version
((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)
0.0.24.0

Server OperatingSystem
((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)
Windows 10 Enterprise

Client OperatingSystem

What is failing
I stripped it down to SSHing into a Ubuntu machine with the ssh.exe binary from my WSL shell, but I don't see all texts during login. Also the bash prompt is not shown, but fortunately the output of eg. an ls command.

Expected output
Expected output should be the same as from a PowerShell terminal:

bildschirmfoto 2017-12-14 um 16 20 46

Actual output

bildschirmfoto 2017-12-14 um 16 13 27

My use-case for ssh.exe in WSL is running it in a vagrant ssh session from WSL. I have to install Vagrant on the Windows side as vagrant.exe to interact with VMware Workstation 14 on the host.

Vagrant comes with an embedded msys/cygwin OpenSSH client and I hoped that the native implementation does a better job on the Windows side as a vagrant ssh looks the same and looks "stuck" until you type commands.

bildschirmfoto 2017-12-14 um 16 09 45

@bagajjal
Copy link
Collaborator

bagajjal commented Dec 14, 2017

This is an expected behavior.
vagrant terminal is not a standard console terminal so your ssh session is treated as "No pty session".

please see the highlighted (in red color) text.
inked33999375-97df718a-e0ea-11e7-82a3-f5effa31c070_li

fyi, we call GetFileType() and expect it to return FILE_TYPE_CHAR (for console terminals).

@StefanScherer
Copy link
Author

StefanScherer commented Dec 14, 2017

Thanks @bagajjal. Right after pasting my screenshot I also saw this message and looked through the sources, even tried -t flag, but no difference.
My screenshot that you have marked shows a direct WSL -> ssh.exe call without Vagrant. So it seems WSL does not forwards that it's a terminal, or at least in a another form as ssh.exe expects it?

@bagajjal
Copy link
Collaborator

"-t" will be ignored because its not a standard terminal.

Include the ssh.exe in the path and try the same from powershell/cmd.exe, that should solve your problem.

@StefanScherer
Copy link
Author

OK. Yes, I know that it works from a PowerShell terminal. Also vagrant ssh works from there. But I would like to switch to WSL and use only this the whole day. Not switching back and forward between this command in WSL and that command in PowerShell.
How can we make WSL + ssh work better together?

@bagajjal
Copy link
Collaborator

Have you tried the ssh that comes with the WSL?

@StefanScherer
Copy link
Author

Yes, of course. That works fine, thanks.
It's only the combination of my everyday tools like Vagrant.
I could try to install Linux Vagrant in WSL, but then I'm not able to run VMware Workstation.
That's why I try Windows version of Vagrant + "alias vagrant vagrant.exe" in WSL. But then the ssh command will be called on the Windows side and here I'm stuck.
It would be much easier if the barrier between WSL and Windows would be lower so everything "just works". I know Microsoft is working on that :-)
I'm figuring out a way for me and my colleages with a set of new company laptops where we have VMware Workstation preinstalled for policy reasons.

@bagajjal
Copy link
Collaborator

bagajjal commented Dec 14, 2017

From vagrant console, you are invoking "windows vagrant.exe" from WSL which requires "windows ssh client"?
Is it possible from powershell, get into WSL and from there you can invoke "windows vagrant.exe"?
If yes then you don't see this problem.
If not then try other ssh clients (like putty/Cygwin)..

From windows openssh side we can't support this scenario because we internally use the windows conhost.. BTW, you can still do all the stuff with "no pty ssh session as well" except that some keystrokes don't work like up/down/left/right, tab, etc.

@StefanScherer
Copy link
Author

Ok, I tried powershell.exe -> ubuntu WSL -> windows vagrant ssh

bildschirmfoto 2017-12-14 um 23 00 43

Now I have to press ENTER multiple times to (eg. ls + 5x ENTER).

Windows Vagrant comes with a embedded Cygwin ssh, same problem there.

I tried the other way around: ubuntu WSL -> powershell.exe > vagrant ssh

bildschirmfoto 2017-12-14 um 23 05 56

Some problem. It really seems to me a problem with ssh.exe

@bagajjal
Copy link
Collaborator

can you try using windows openssh client instead of vagrant ssh and try the same steps
powershell -> Ubuntu WSL -> vagrant using windows openssh client (not embedded Cygwin ssh client).

@StefanScherer
Copy link
Author

OK, I've tried serveral things now without Vagrant, just to keep it simpler and third party tools out of the way. Here are five scenarios:

Ubuntu WSL -> Ubuntu ssh
works as expected, as everything keeps in the WSL world

wsl-ssh-fine

Ubuntu WSL -> windows openssh client
not everything visible

wsl-ssh exe-not-ok

Ubuntu WSL -> powershell.exe -> windows openssh client
not everything visible, powershell.exe itself as a shell also looks good, so it's able to use the conhost/terminal from the WSL

wsl-powershell-ssh exe-not-ok

PowerShell -> windows openssh client
works as expected, as everything keeps in the Windows world

powershell-ssh exe-fine

PowerShell -> Ubuntu WSL -> windows openssh client
not everything visible

powershell-wsl-ssh exe-not-ok

@bagajjal
Copy link
Collaborator

Thanks for trying different configurations.

I debugged further. It's not possible to have ssh pty session when launched from WSL (Windows subsystem for Linux) no matter you logged into WSL from powershell/cmd/from other console terminal.

Here is the detailed explanation,
windows ssh.exe allocates a pty session only if ssh.exe has access to the console terminal.
sshd will instruct the ssh.exe client to move the cursor position, set the console properties, etc.
If we launch the ssh.exe client from WSL (Windows subsystem for Linux), the ssh.exe will be launched as a windows process whose STDIN/OUT will be pipes to WSL, so ssh.exe client can't control the console terminal.

@StefanScherer
Copy link
Author

Thanks @bagajjal for looking into it and asking in WSL project. I've subscribed these issues.
Well it seems this is a hard problem for the tech industry:
Look at https://hashicorp.com and scroll down to the bottom. There, in dark gray letters :-) It's a running gag at HashiCorp.

@bagajjal
Copy link
Collaborator

Closing this issue as it's related to WSL.
Please track the issue on microsoft/WSL#2406

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

No branches or pull requests

2 participants