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

docker ssh with OpenSSH-Win32 does not work with Powershell and CMD login shell #1376

Closed
nunix opened this issue Sep 14, 2018 · 3 comments
Closed

Comments

@nunix
Copy link

nunix commented Sep 14, 2018

Description
When trying to connect with docker -H ssh://<host> to a Windows host running OpenSSH-Win32, if the login shell is PowerShell or CMD, the client cannot connect to the daemon.
However, if the login shell is bash (WSL), then the client can connect to the daemon.

Complete examples with the 2 scenarios
image

Steps to reproduce the issue:

  1. Set registry key HKLM:\SOFTWARE\OpenSSH\DefaultShell to C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
    image

  2. Try to connect > we get an error

docker -H ssh://localhost version
nunix@localhost's password:
nunix@localhost's password:
Client: Docker Engine - Community
 Version:           18.09.0-ce-beta1
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        78a6bdb
 Built:             Thu Sep  6 22:42:13 2018
 OS/Arch:           windows/amd64
 Experimental:      false
error during connect: Get http://docker/v1.39/version: command [ssh localhost -- docker system dial-stdio] has exited with exit status 1, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr="the raw stream connection does not implement halfCloser\n"

image

  1. Set registry key HKLM:\SOFTWARE\OpenSSH\DefaultShell to C:\WINDOWS\System32\bash.exe
    image

  2. [Optional] if not running, start the npiperelay.exe from the WSL shell

sudo docker-relay &
  1. Try to connect > we succeed
docker -H ssh://localhost version
nunix@localhost's password:
Client: Docker Engine - Community
 Version:           18.09.0-ce-beta1
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        78a6bdb
 Built:             Thu Sep  6 22:42:13 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0-ce-beta1
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.3
  Git commit:       78a6bdb
  Built:            Thu Sep  6 22:57:45 2018
  OS/Arch:          windows/amd64
  Experimental:     true

image

Describe the results you received:
When using Powershell or CMD as the ssh login shell, it tries to connect twice (it's not a wrong password) and then it generates an error when trying to connect to the daemon.

Describe the results you expected:
While using Powershell or CMD as the ssh login shell, it should not request twice the password and directly connect to the daemon.
In fewer words, the same behavior as for the bash login shell

Additional information you deem important (e.g. issue happens only occasionally):
When trying to connect with the WSL client, there's an additional information
image

Output of docker version:

PS C:\WINDOWS\system32> docker version
Client: Docker Engine - Community
 Version:           18.09.0-ce-beta1
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        78a6bdb
 Built:             Thu Sep  6 22:42:13 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0-ce-beta1
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.3
  Git commit:       78a6bdb
  Built:            Thu Sep  6 22:57:45 2018
  OS/Arch:          windows/amd64
  Experimental:     true

Output of docker info:

PS C:\WINDOWS\system32> docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 2
Server Version: 18.09.0-ce-beta1
Storage Driver: windowsfilter (windows) lcow (linux)
 Windows:
 LCOW:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 17754 (17754.1.amd64fre.rs5_release.180831-1429)
Operating System: Windows 10 Enterprise Version 1809 (OS Build 17754.1)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 7.409GiB
Name: hpnix
ID: 3EN3:ZEK2:J34Z:G67X:HO33:VXOV:IN5E:I67M:4BSZ:YAO5:MBTO:TSO3
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 26
 System Time: 2018-09-14T20:58:21.8133065+02:00
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.):
Configuration on WSL side:

Configuration on Windows side:

@AkihiroSuda
Copy link
Collaborator

AkihiroSuda commented Sep 15, 2018

docker system dial-stdio failing on the SSH server side, because docker client on the SSH server got some unsupported connection stream to the Docker daemon.

Maybe DOCKER_HOST is set to different value when the shell is set to Powershell?

@nunix
Copy link
Author

nunix commented Sep 15, 2018

I just tried different setups and unfortunately, I get the same error:

  1. No DOCKER_HOST set > error
  2. DOCKER_HOST set to npipe:// in $PSHOME\Profile.ps1 > error

However, if I SSH and then run Docker, it works (even without DOCKER_HOST set)
image

And testing further, actually using wsl.exe, throws the same error. So only using bash.exe works with OpenSSH-Win32 (at least for now)

@nunix
Copy link
Author

nunix commented Oct 28, 2019

Sorry for the delay, this now works fine. Thanks a lot for the work

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