SPOILER: It works fine out of the box if you have git’s bin directory in your path.
I was chatting recently with friend of mine, David Jacoby, and he mentioned a desire to purchase a Mac for development. Since he already had a Windows machine, I asked him why.
(A few years ago, I would have simply nodded in agreement. But Windows has been doing a great job lately of putting open source development tech onto their OS. Either by baking it into Visual Studio or paying the open source developers to port it like they did with node.)
He tells me there’s some difficulty when you mix ssh, vagrant, and windows (or at least, there was a difficulty).
I was planning to use vagrant, so I needed to find out for myself. First off I googled vagrant putty ssh
, and then read the linked stack overflow question.
Supposedly it’s been fixed for 10 months. But it was unclear to me if the vagrant ssh on windows fix works with putty or with the ssh command installed with git.
Since I’d have to test to be sure anyway, I installed vagrant and virtual box.
I followed the Vagrant Getting Started instructions:
$ vagrant init precise32 http://files.vagrantup.com/precise32.box
$ vagrant up
Vagrant up
returned an error, but it was a very helpful error that told me to put the VBoxManage.exe binary on my path. I found it in C:\Program Files\Oracle\VirtualBox, added that to my path, and ran vagrant up
again.
And away it went!
Bringing machine ‘default’ up with ‘virtualbox’ provider…
[default] Box ‘precise32’ was not found. Fetching box from specified URL for
the provider ‘virtualbox’. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading or copying the box…
Extracting box…ate: 5401k/s, Estimated time remaining: –:–:–)
Successfully added box ‘precise32’ with provider ‘virtualbox’!
[default] Importing base box ‘precise32’…
[default] Matching MAC address for NAT networking…
[default] Setting the name of the VM…
[default] Clearing any previously set forwarded ports…
[default] Creating shared folders metadata…
[default] Clearing any previously set network interfaces…
[default] Preparing network interfaces based on configuration…
[default] Forwarding ports…
[default] — 22 => 2222 (adapter 1)
[default] Booting VM…
[default] Waiting for machine to boot. This may take a few minutes…
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.
Guest Additions Version: 4.2.0
VirtualBox Version: 4.3
[default] Mounting shared folders…
[default] — /vagrant
Now for the moment of truth, I type in vagrant ssh
and got:
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@precise32:~$
So it works great. The only question I have left is, “Is this relying on the SSH command that’s already on my machine? If so, did it come with PowerShell, installing Git on my path, posh-git, Github for Windows, or some forgotten tool?
Update: In the comments, Dave Jacoby posted a command to check your path: ($env:Path).Replace(‘;’,”`n”)
. We determined that having Git’s bin directory in your path is required.
I am now able to get it working, but with Git Shell, a cygwin-ish bash shell. That’s OK, but there’s a big distinction between the world of c:\foo and /usr/bin/bar that bash really carpets over. If I could tell where that bash’s /bin/ssh was, I could just add it to PowerShell’s shell.
If you could run this in your PowerShell, Robert, we could probably figure out what’s in your Path and not in mine.
($env:Path).Replace(‘;’,”`n”)
Here’s mine:
PS C:\Users\jacoby\Vagrant> ($env:Path).replace(‘;’,”`n”)
%SystemRoot%\system32\WindowsPowerShell\v1.0\
C:\Program Files\Microsoft HPC Pack 2008 R2\Bin\
C:\Program Files (x86)\ActiveState Komodo Edit 8\
C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live
C:\windows\system32
C:\windows
C:\windows\System32\Wbem
C:\windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Lenovo\Bluetooth Software\
C:\Program Files\Lenovo\Bluetooth Software\syswow64
C:\Program Files (x86)\Windows Live\Shared
C:\strawberry\c\bin
C:\strawberry\perl\site\bin
C:\strawberry\perl\bin
C:\HashiCorp\Vagrant\bin
c:\Users\jacoby\Dropbox\Scripts
ah that’s a huge help. thanks.
So I have this in my path, and there is indeed an ssh.exe in it.
Pretty sure I picked the middle option when installing Git, the one that adds git to your path but not ALL the bash tools.
I have GitHub for Windows, which works off a portable Git Shell deep in AppData. Installing Git for Windows as we speak. That should make this sane.