Skip to content

Instantly share code, notes, and snippets.

@thejohnfreeman
Last active April 3, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejohnfreeman/6838a0f98811e9fa170a8a9807e898a0 to your computer and use it in GitHub Desktop.
Save thejohnfreeman/6838a0f98811e9fa170a8a9807e898a0 to your computer and use it in GitHub Desktop.
Windows, SSH, Docker Machine

A developer named James Nugent described in a blog post the Packer template he wrote for creating a Windows AMI with OpenSSH installed and configured (by default, there is no SSH server installed or running on the free Windows AMIs owned by Amazon). He had previously shared code for using WinRM to automate a Windows instance.

I used his code to create my own AMI in us-east-2: ami-03247dd53ecd53cba. You can try it out yourself. The SSH user is Administrator.

Sadly, there is a long delay between when an AWS instance launched with this AMI enters the state "running" and when the SSH server on it is running, for the same reason that password data is not immediately available, up to 15 minutes. This is just an unfortunate consequence of deploying a service (SSH) on Windows it seems.

Docker Machine is smart enough to wait for "SSH to be available", but it runs into an error when Docker Machine tries to provision it. There is an open issue in the Docker Machine project for provisioning Windows machines. They had not started working on it because there was no easy, non-interactive way out-of-the-box for connecting to a Windows machine.

Error creating machine: Error detecting OS: Error getting SSH command: ssh command error:
command : cat /etc/os-release
err     : exit status 1
output  : cat : Cannot find path 'C:\etc\os-release' because it does not exist.
At line:1 char:1
+ cat /etc/os-release
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\etc\os-release:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment