Search code examples
vagrantvirtual-machineapache-stormvagrant-windows

I can't connect to a Vagrant handled VM: `ssh` executable not found in any directories in the %PATH%, but I have it


I am absolutly new in Vagrant and I have the following problem. I am using Windows 8.1.

I have done the following operations:

  1. First I have download this into a folder of my host from github, by this statment:

    git clone https://github.com/Udacity/ud381

  2. Then I performed:

    vagrant up

that downloaded the Vagrant Box containing the guest VM

and when now I perform the vagrant up command I obtain this message:

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'udacity/ud381' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due

==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default: Failed connect to atlas.hashicorp.com:443; No error
==> default:
==> default: If you want to check for box updates, verify your network connectio
n
==> default: is valid and try again.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 5000 => 5000 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Andrea/Documents/workspaces/Real-Time/ud381
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.

I think that it is correct but I am not absolutly sure about it because it seems that I have some warning message but it say: default: Machine booted and ready! so I think that it is ok (is it ok?)

Then I try to connect to it by SSH performing the vagrant ssh statment but I obtain this error message:

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use your favorite SSH client with the following
authentication information shown below:

Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/Andrea/Documents/workspaces/Real-Time/ud381/.vagrant/machi
nes/default/virtualbox/private_key

Searching on Google I found that to use this statment I need the git path into the PATH environment variable. I check and I have it setted, infact inside the PATH variable I have these 2 values:

C:\HashiCorp\Vagrant\bin;C:\Program Files\Git\bin

the first one is the vagrant path and the second one the Git path.

So this is not the problem. Searching online I also found this StacOverflow discussion:

`ssh` executable not found in any directories in the %PATH%

that send to this link for this kind of problem: https://gist.github.com/haf/2843680

In this link it show how to modify an ssh.rb file into this folder C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb

The problem is that I have not this folder but something like this:

C:\HashiCorp\Vagrant\embedded\lib\ruby\gems\2.0.0\gems\

and this folder don't contain the *vagrant-1.0.3\lib\vagrant* subfolder (that contain the ssh.rb file) but contain 3 directory respectivelly named rake-0.9.6, rdoc-4.0.0 and test-unit-2.0.0.0 that don't contain the ssh.rb file.

Searching this file I found 2 different version into these folder:

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v1\config

and

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v2\config

I think that maybe the difference from the tutorial could depend by the fact that it is referred to a very old Vagrant version (it is 4 year old) and I have installed the 1.7.4 version of Vagrant.

So how can I connect in SSH to the VM handled by Vagrant?


Solution

  • The error message

    C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh `ssh`
    executable not found in any directories in the %PATH% variable. Is an 
    SSH client installed?
    

    states that the cli you are currently using (wich is probably cmd or powershell when you are working under windows) could not find an installed ssh client. That means your cli was not able to find a programm that can handle connecting to another server (in this case your vagrantbox) via ssh.
    This is a pretty common scenario since windows does not come with an ssh client out of the box (unlike ubuntu or osx).

    AFAIK there is no ssh program/command that you can easily install and put into your PATH so that it will work with cmd.

    What you probably want to do in this situation is installing a different cli that comes with these features. You have several Options here, they are also stated in the error message:

    Try installing Cygwin, MinGW or Git, all of which
    contain an SSH client
    

    I recommend you using Git Bash which you probably already have installed on your system since you are using git.

    So to perform a vagrant ssh your first step will be starting Git Bash either by executing the program itself (which comes with git, on my system it could be found under: C:\Program Files\Git\git-bash.exe) or by right clicking in a directory listing in Windows Explorer and selecting Git Bash here (this will only work if you checked a certain box upon Git install).
    It will open a new cli which works with linux like commands. You should be able to cd into your vagrant directory and perform a vagrant ssh now.

    The solution you linked to in your question no longer seems to work since the path of the ssh client comming with git seems to have changed.