If you are not sure what it is or why you should use it, please read these:
To use Vagrant, you need three applications:
- PuTTY or Git for Windows to use SSH
Here is an example:
C:\vagrant>vagrant init precise32 http://files.vagrantup.com/precise32.box
Bringing machine 'default' up with 'virtualbox' provider...
[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
`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 the PuTTY SSH client with the following
authentication information shown below:
Private key: C:/Users/kkim/.vagrant.d/insecure_private_key
As you see here, it can't find ssh.exe and here are a few solutions. Please note that the default id/password is vagrant/vagrant:
- With Git
- Add path to ssh.exe to PATH environment variable. If you installed git for Windows from below link (see Download section below), it's here:
[UPDATE-20170813] Git ssh.exe is in different folder in the latest package -- it's in C:\Program Files\Git\usr\bin
C:\Program Files (x86)\Git\bin
Add to the environment variable or set it as:
C:\vagrant>set PATH=%PATH%;C:\Program Files\Git\usr\bin
C:\vagrant>set PATH=%PATH%;C:\Program Files (x86)\Git\bin
Downside with this method is ssh runs within cmd window, and unless you use something like console 2, cmd window cannot be resized. (You probably want to use console2. It's a lot better than default cmd; it provides tab, and also cygwin, powershell can be used within it.)
- Method (a), using PuTTY, ssh to 127.0.0.1:2222 with the default id/password.
- Method (b), using PuTTY's PuTTYgen to convert above private key to putty's format, and use that to ssh to vagrant VM.
- Method (c), use this plugin, https://github.com/nickryand/vagrant-multi-putty
Install it by issuing this command:
C:\vagrant>vagrant plugin install vagrant-multi-putty
But you still need to have the path set correctly where putty.exe is:
C:\vagrant>set PATH=%PATH%;C:\Program Files (x86)\PuTTY
when you enter vagrant putty, it will spawn putty window and connect to the VM.
$ ssh -p 2222 localhost -l vagrant
To destroy the VM:
- Windows 7, 64-bit
- Vagrant v1.3.5
- VirtualBox v4.3.4