Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

docker-machine cannot open SSH session to a newly created Hyper-V VM #4053

@WojtekKozaczynski

Description

@WojtekKozaczynski

While creating a Hyper-V VM on a Windows 10 machine the docker-machine gets stuck on creating a SSH session to that VM.

My Environment

  • Windows 10 Pro
  • docker version 17.03.1-ce, build c6d412e
  • docker-machine version 0.10.0, build 76ed2a6
  • OpenSSH 7.4

Description

I have enclosed a file ([createCommand.txt (https://github.com/docker/machine/files/908025/createCommand.txt)) with the messages from executing the following command

docker-machine -debug create -d hyperv --hyperv-virtual-switch ExternalWireless worker1

Everything looks fine until the script tries to open a SSH session to the newly created VM. Each attempt looks like this

Waiting for SSH to be available...
Getting to WaitForSSH function...
(worker1) Calling .GetSSHHostname
(worker1) DBG | [executing ==>] : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive ( Get-VM worker1 ).state
(worker1) DBG | [stdout =====>] : Running
(worker1) DBG |
(worker1) DBG | [stderr =====>] :
(worker1) DBG | [executing ==>] : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive (( Get-VM worker1 ).networkadapters[0]).ipaddresses[0]
(worker1) DBG | [stdout =====>] : 192.168.0.108
(worker1) DBG |
(worker1) DBG | [stderr =====>] :
(worker1) Calling .GetSSHPort
(worker1) Calling .GetSSHKeyPath
(worker1) Calling .GetSSHKeyPath
(worker1) Calling .GetSSHUsername
Using SSH client type: external
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i C:\Users\wojtek\.docker\machine\machines\worker1\id_rsa -p 22] C:\Program Files\OpenSSH\ssh.exe <nil>}
About to run SSH command:
exit 0
SSH cmd err, output: exit status 255:
Error getting ssh command 'exit 0' : ssh command error:
command : exit 0
err     : exit status 255
output  :

and after 60 such attempts the script quits with the message

Error creating machine: Error detecting OS: Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded
notifying bugsnag: [Error creating machine: Error detecting OS: Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded]

The VM is created, it is given an IP address, and it starts. The interesting part is that I can create SSH session from the command line using exactly the same SSH commands as in the script (I have enclosed a file sshConnection.txt with debug messages from execution of that command)

ssh -v [email protected] -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=DEBUG -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none -o IdentitiesOnly=yes -i C:\Users\wojtek\.docker\machine\machines\worker1\id_rsa

This means that SSH server works fine on the VM and the certificate checks out. Just for completeness I tested creating a SSH session from the VM to the Windows 10 host machine, and it also works fine. Also, after reading a few posts, I turned the firewall off but the problem still persists.

Below is what I get when I ask the docker-machine to (a) list the VM docker hosts and (b) create SSH session to the new VM

C:\WINDOWS\system32>docker-machine ls
NAME      ACTIVE   DRIVER   STATE     URL                        SWARM   DOCKER    ERRORS
worker1   -        hyperv   Running   tcp://192.168.0.108:2376           Unknown   Unable to query docker version: Get https://192.168.0.108:2376/v1.15/version: x509: certificate signed by unknown authority

C:\WINDOWS\system32>docker-machine ssh worker1
exit status 255

Notice that the 255 exit status is the same as in the create script.

Why does the same SSH command fail when executed in a docker-machine script and succeeds when executed from the command line? How do I further debug the issue?

Cheers, Wojtek

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions