Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

SSH alternative to Cygwin #4

Closed
dylanmei opened this issue Oct 4, 2013 · 13 comments
Closed

SSH alternative to Cygwin #4

dylanmei opened this issue Oct 4, 2013 · 13 comments

Comments

@dylanmei
Copy link
Collaborator

dylanmei commented Oct 4, 2013

Regarding issue #3 comment by @sneal: In fact I'd rather not install Cygwin if I could.

I am having some success using OpenSSH for Windows 5.3 from coming from Chocolatey and also the 6.2 from mls-software.

The initial ssh handshake and scp operation to copy over .vbox_version work great but any subsequent scp operations blow up. I'm hoping it's something I can fix from the sshd configuration side, but it's strange how I can ssh and scp manually just fine but packer can't do more than one run against it. Investigation ongoing....

If there are similar ideas out there, I'd like to hear about it before I go too far down the rabbit hole.

@StefanScherer
Copy link
Collaborator

I have tried to use FreeSSHD instead of Cygwin with Packer, but it just connects and disconnects. That is what I can see in FreeSSHD.log.
You might have a look at my configuration at https://github.com/StefanScherer/basebox-packer/tree/master/template/stefan-win7x64-freesshd

@dylanmei
Copy link
Collaborator Author

dylanmei commented Oct 4, 2013

Here is output from Packer with OpenSSHd for Windows 5.3.
https://gist.github.com/dylanmei/6831339

@StefanScherer Thanks for pointing me to freeSSHD. What packer output are you getting with this?

@StefanScherer
Copy link
Collaborator

@dylanmei Thanks for the hint with the log file. I forgot about that. The packer log file says following error:
handshake error: handshake failed: ssh: no common algorithms
Here is a list of supported algorithms in freeSSHD:
http://stackoverflow.com/questions/18998473/failed-to-dial-handshake-failed-ssh-no-common-algorithms-error-in-ssh-client

So, freeSSHD seems to be a dead end. I will stop my investigations here.
I do not need ssh after creating the basebox, I want to use vagrant-windows with winrm. So how about a removal script that removes Cygwin SSHD or any other sshd from the windows box with packer's shutdown_command?

@joefitzgerald
Copy link
Owner

@StefanScherer it would be fairly trivial to create a removal script. I'll take a look at doing that tomorrow, but please note that it will only run on first boot of the resulting box. I.e. you'll be distributing boxes with Cygwin / SSHd, but they will not be available once the box starts up for the first time.

@dylanmei
Copy link
Collaborator Author

dylanmei commented Oct 7, 2013

Because packer doesn't need SSH anymore once shutdown_command is issued, there's no reason why shutdown_command = "cmd /c my-shutdown.bat" can't run a script that tears down Cygwin/OpenSSH.

Forgot to add, the reason I'm investing so much time in OpenSSH 6.2 package is that Cygwin recently broke their silent installer. http://cygwin.com/ml/cygwin/2013-10/msg00006.html. Even if they fix it soon, it's left me with a bad taste.

Shifting to the smaller OpenSSH 6.2 is going really well although I'm having to re-write our .sh provisioning files as .bat since the there's not as much unix-y stuff here.

@joefitzgerald
Copy link
Owner

@dylanmei Good point - and makes sense. Excited to see where you get to on the conversion to .bat + OpenSSH.

@StefanScherer
Copy link
Collaborator

I like the idea of removing cygwin before shutting down the VM. I have tried it in a vagrant box, my first try of a simple bat script is here https://gist.github.com/StefanScherer/6874808
I stop sshd as late as possible, but perhaps this is not needed, because packer waits until VM is shut down and so the SSH connection could be cut off earlier.
Is there a more clean way to uninstall cygwin?

@joefitzgerald
Copy link
Owner

@StefanScherer http://cygwin.com/faq/faq.html#faq.setup.uninstall-all Looks like it needs to be done manually, and you've got most of the steps. Why not just do a sleep at the start of the script to give packer time to disconnect from ssh? Then you can remove the extra rmdir /s /q cygwin step prior to shutting down sshd.

The missing link is running the batch script and terminating immediately (i.e. we don't want to do a cmd /c - we probably want to use start) in the shutdown script.

@StefanScherer
Copy link
Collaborator

@joefitzgerald Yes, starting the command into the background is a good idea. I have tried it in my win7 basebox and committed my working version into https://github.com/StefanScherer/basebox-packer/tree/master/template/stefan-win7x64.
I have replace the shutdown command to call the batch script and added the batch script to the floppy.
Short before the VM shutted down, the desktop icon of cygwin disappeared. A good sign.

@joefitzgerald
Copy link
Owner

@dylanmei Where'd you get to with the switch to OpenSSH - can I help? Would love to switch as soon as possible.

@dylanmei
Copy link
Collaborator Author

dylanmei commented Oct 9, 2013

Actually I'm very close. I've run the gauntlet on 2012 vmware/virtualbox and am just now validating 2008 r2 on virtualbox.

  • Packer 3.9 seems to have an issue with including our Vagrantfiles in the box, so I had to go back to 3.7 and lost some small features (virtualbox -> guest_additions_attatch).
  • SSH is left on the box but it will be a no-brainer to remove it using the shutdown trick.
  • I haven't yet checked that I can use puppet/chef provisioner once they are installed.
  • We "should" be able to use powershell from the shell provider but can't get it to upload ps1 files (?!)

I can make a pull req on this now if you are interested in smoking out any issues?
https://github.com/dylanmei/packer-windows/tree/using_openssh

@joefitzgerald
Copy link
Owner

Yes, please - happy to take a look over a PR, and fix anything that comes up. I'm stubborn so I'll try to dig more with packer 3.9, also. :)

@dylanmei
Copy link
Collaborator Author

dylanmei commented Oct 9, 2013

Being stubborn is a requirement to working on this stuff ;)

stefanschneider pushed a commit to stefanschneider/packer-windows that referenced this issue Aug 21, 2016
…tainerhost

Fix Install-ContainerHost.ps1 by downloading older commit
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants