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

I am absolutly new in Vagrant and I have the following problem. I am using Windows 8.1.
I have done the following operations:
First I have download this into a folder of my host from github, by this statment:
git clone https://github.com/Udacity/ud381
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?

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.

See Ygor Thomaz' comment in the other SO post you found. The PATH path has changed to:
C:\Program Files\Git\usr\bin
..so run this in cmd:
set PATH=%PATH%;C:\Program Files\Git\usr\bin
Related:
How do you update the GIT_SSH environment variable on Windows
https://stackoverflow.com/a/16247703/1869660

Related

how to solve this SMB share folder when vagrant sync folder fail in this case?

I have a vagrant in my Win10 PC.
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.synced_folder "D:/Users/88888888/vagrant_proj/vagrant_data", "/vagrant_data"
config.vm.network "private_network", ip: "172.22.244.28"
end
When I vagrant up my vm, I get below error when sync folder:
MINGW64 ~/vagrant_proj/vagrant_vm/vmware_desktop_centos7
$ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.22.244.28
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.22.244.28:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]): ABC\88888888
default: Password (will be hidden):
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
default: Password (will be hidden): Aircraft04!
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Mounting SMB shared folders...
default: D:/Users/88888888/vagrant_proj/vagrant_data => /vagrant_data
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o vers=2.0,credentials=/etc/smb_creds_vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //10.0.129.112/vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593 /vagrant_data
The error output from the last command was:
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
how to solve this SMB share folder?
the version is below:
$ vagrant.exe --version
Vagrant 2.2.19
and I use the vagrant HyperV provider.

Laravel 5.3 Homestead Installation on Win 10

Following >> https://laravel.com/docs/5.3/homestead
bash init.sh
cp: overwrite '/c/Users/myuser/.homestead/Homestead.yaml'? y
cp: overwrite '/c/Users/myuser/.homestead/after.sh'?
cp: overwrite '/c/Users/myuser/.homestead/aliases'?
Homestead initialized!
I don't know if these needs to be overwritten ?
Also , I configure homestead.yaml
folders:
- map: ~/Homestead
to: /home/vagrant/Code
It is showing error[The host path of the shared folder is missing: ~/Homestead]
My homestead installation is
$ pwd
/Homestead
I am sure some steps are missing can someone help
Installation method - Per Project Installation
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Running provisioner: shell...
SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.
It is a fresh installation !
vagrant destroy && up
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: Warning: Authentication failure. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Yes, you should overwrite these files so as to have a clean installation of Homestead (just in case). Now, the reason you are getting this error is because your YAML configuration is wrong. Assuming you have your Laravel code in a Code folder in your Documents folder, your YAML should look like this (NB: this is Windows specific!):
folders:
- map: "C:/Users/Username/Documents/Code"
to: "/home/vagrant/Code"
You need to map the folder containing your local code to a folder in your virtual machine. This will then be set up using shared folders. This way, any code changes in your Code folder will be mirrored to your VM.
Personally, I prefer the Per Project Installation because I can have multiple projects running on different VMs mapped to different domains, at the same time. Check it out here: https://laravel.com/docs/5.3/homestead#per-project-installation

vagrant up timing out on Windows 10

I'm trying to boot up a vagrant instance but it seems to hang at the default: SSH auth method: private key part no matter what I do. I'm new to vagrant so it's entirely possible that there's something I haven't done but should have.
System info:
Windows 10 build 10586.420
Vagrant 1.8.4
VirtualBox 5.0.22 r108108
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> 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: 22 (guest) => 2222 (host) (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
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
I had a look around for similar issues and people have suggested making sure Hyper-V is disabled (which it is) and enabling the virtualbox GUI to see if there are any other errors that aren't being put in the command line.
When I open the virtualbox GUI, I see a username/password prompt (see below):
I've tried entering the default vagrant username/passwords and these work but the vagrant up script still hangs and eventually crashes.
Any help would be much appreciated.
Thanks.

Launching a Vagrant VM inside Travis-CI

How do you launch a Virtualbox VM using Vagrant inside Travis-CI?
I know launching a VM inside a VM is sometimes not supported, but there have been reported successes with this specific configuration.
I'm trying to setup a continuous integration server to run unittests for my sysadmin tool, to test it across different operating systems and Python versions. It uses Tox to handle initializing the various Python virtual environments and Pytest to run the tests and wrap Vagrant to setup and teardown the Virtualbox VM. It runs fine on my Ubuntu 14 localhost, but in Travis, Vagrant times out trying to boot a Virtualbox VM:
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: functional_tests_default_1463515960654_71459
==> 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: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
...
The job exceeded the maximum time limit for jobs, and has been terminated.
Since it's not giving me any details, I'm not sure how to diagnose the problem. I tried to enable more output with export VAGRANT_LOG=DEBUG; but that didn't show anything useful and exceeded Travis's maximum log size. I also tried increasing the timeout, and the memory allocation to 1GB, but neither helped.
The only odd thing I've noticed, that I've not been able to explain, is this message from sudo apt-get -y install -q virtualbox-ose-dkms virtualbox --fix-missing:
Module build for the currently running kernel was skipped since the
kernel source for this kernel does not seem to be installed.
However, immediately before this, the command to install kernel source succeeds:
sudo apt-get -y --force-yes install linux-headers-`uname -r`
How do you launch a Vagrant/Virtualbox VM inside Travis-CI?
Sadly this is not supported by Travis-CI and there's no plan to do it in the near future. Check the following ticket: https://github.com/travis-ci/travis-ci/issues/6060
Since Travis is running your build in a virtualized container (OpenVZ) you could try with a 32-bit VM. That could work, but I haven't tested.
From the end of 2019 it is possible to run Vagrant on TravisCI! All you have to do, is to switch to libvirt & KVM provider instead of virtualbox on Travis - see this so answer for a complete HowTo and this fully comprehensible example project on GitHub: https://github.com/jonashackt/vagrant-travisci-libvrt
See this TravisCI build for example:
If you don't want to use the libvirt provider locally, you can simply use one of the generic Vagrant Box images from Vagrant Cloud, since they support both virtualbox (locally) and libvirt (on TravisCI).

Using rsync on windows with vagrant running a CoreOS VM

I am using windows 8.1 Pro pc running vagrant and cygwin's rsync.
I am configuring as such:
config.vm.synced_folder "../sharedFolder", "/vagrant_data", type: "rsync"
And when I execute vagrant up I get the following error:
C:\dev\vagrantBoxes\coreOS>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'yungsang/coreos' is up to date...
==> 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: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: core
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Rsyncing folder: /c/dev/vagrantBoxes/sharedFolder/ => /vagrant_data
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /c/dev/vagrantBoxes/sharedFolder/
Guest path: /vagrant_data
Command: rsync --verbose --archive --delete -z --copy-links --chmod=ugo=rwX --no-perms --no-owner --no-group --rsync-path sudo rsync -e ssh -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/d
ev/null -i 'C:/Users/aaron.axisa/.vagrant.d/insecure_private_key' --exclude .vagrant/ /c/dev/vagrantBoxes/sharedFolder/ core#127.0.0.1:/vagrant_data
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: change_dir "/c/dev/vagrantBoxes/sharedFolder" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at /usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/main.c(1052) [sender=3.0.9]
I assume it is an issue with how it is changing the directory path to /c/dev rather than C:\dev
like I commented in the github-issue, following line in your Vagrantfile will most certainly fix your problem
ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin"
since this is local in your Vagrantfile, the source-files can be kept untouched
workaround: just ln -s /cygdrive/c/ /c on cygwin terminal
There is a hacky way to fix this (worked for me anyway) where you have to change
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
to
hostpath = "/cygdrive" + Vagrant::Util::Platform.cygwin_path(hostpath)
on line 43 in C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-[VERSION]\plugins\synced_folders\rsync\helper.rb
It's different for 1.5.x, you can read this thread here about it: https://github.com/mitchellh/vagrant/issues/3230
I will, however, be the first to admit that editing the core is far from ideal.
From my testing, if you are using cygwin, use the solution by #osroot25 .
If you are using cwRsync and do not have cygwin, there is no workaround using Vagrant except editing the source code as #Andrew Myers details. Tested using Vagrant v1.6.5.
My workaround that works for me is to bypass Vagrant altogether and use cwRsync directly. This works for me because I am syncing a folder that hardly ever changes. I might change it quite a few times in one day (so I have to remember step 2 below each time), but I then go weeks (or months) without any changes. Remember that to use cwRsync you have to edit and use the cwrsync.cmd script. Attempting to access the rsync.exe command directly or by adding it to your path will fail. Step 1: I added the following line to the end of cwrsync.cmd (in the installed folder):
rsync -re "ssh -p 2222" /cygdrive/b/VCS/packages/ vagrant#localhost:packages --exclude ".git/"
Step 2: I have a separate cmd window open that I run the cwrsync.cmd using the full path. Then if I need to sync changes onto the VM, I activate that window, up-arrow, return and updating is instant!
Modifying ENV to set cygwin fix by #osroot25 doesn't work with cwRsync because when you force cygwin detection, the "vagrant ssh" command will not work because it requires the cygpath command in cygwin, which you won't have, so you cannot ssh into the VM. Well you can if you use the ssh command directly with all the right options.

Resources