Skip to content

Instantly share code, notes, and snippets.

@haf
Created May 31, 2012 14:19
Show Gist options
  • Save haf/2843680 to your computer and use it in GitHub Desktop.
Save haf/2843680 to your computer and use it in GitHub Desktop.
Get SSH working on Vagrant/Windows/Git

If you are using vagrant, you probably-statistically are using git. Make sure you have its binary folder on your path, because that path contains 'ssh.exe'.

Now, modify C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb to comment out the faulty Windows check and add a real SSH check:

# if Util::Platform.windows?
  # raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],
                                       # :port => ssh_info[:port],
                                       # :username => ssh_info[:username],
                                       # :key_path => ssh_info[:private_key_path]
# end

which = Util::Platform.windows? ? "where ssh >NUL 2>&1" : "which ssh >/dev/null 2>&1"
raise Errors::SSHUnavailable if !Kernel.system(which)

Now you can do vagrant ssh. Happy camper again!

@julianfrank
Copy link

Try adding the path D:\Program Files\Git\usr\bin

@ITedInnovator
Copy link

Thanks Julian Frank but for me it was the C drive:
set PATH=%PATH%;C:\Program Files\Git\usr\bin

@victorhtorres
Copy link

The route C:\Program Files\Git\usr\bin works fine for me. The first solution should not be necessary.

@charlesaraya
Copy link

Adding C:\Program Files\Git\usr\bin worked for me too.

@SnehaSahu05
Copy link

..git\usr\bin works perfect, the previous solution ..git\bin is not needed as path variable.
thanks @rekestas

@sagaroe
Copy link

sagaroe commented Dec 29, 2016

Added "C:\Program Files\Git\usr\bin" in PATH and it worked for me. thanks :)

@jameszrx
Copy link

jameszrx commented Apr 9, 2017

Git\usr\bin works for me too! Excellent solution! Thanks a lot!

@karan1276
Copy link

Yup "C:\Program Files\Git\usr\bin" works, Thanks :)

@cancerberoSgx
Copy link

In my case even adding ssh to the PATH didn't solve the problem. What I had to do is connect to vagrant with ssh manually. After executing vagrant up, instead of executing vagrant ssh, I do this:

ssh [email protected] -p 2222
And the password is "vagrant"

For getting all the information about the ip, port and user you can use

vagrant ssh-config
Ope this helps somebody...

@marcosronaldo
Copy link

@cancerberoSgx Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment