If you are not sure what it is or why you should use it, please read these:
http://www.vagrantup.com/about.html
http://docs.vagrantup.com/v2/why-vagrant/index.html
http://superuser.com/questions/584100/why-should-i-use-vagrant-instead-of-just-virtualbox
To use Vagrant, you need three applications:
- VirtualBox
- Vagrant
- PuTTY or Git for Windows to use SSH
Here is an example:
C:\>mkdir vagrant
C:\>cd vagrant
C:\vagrant>vagrant init precise32 http://files.vagrantup.com/precise32.box
C:\vagrant>vagrant up
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
C:\vagrant>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 the PuTTY SSH client with the following
authentication information shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
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\Git\usr\binC:\Program Files (x86)\Git\bin
Add to the environment variable or set it as:
C:\vagrant>set PATH=%PATH%;C:\Program Files\Git\usr\binC:\vagrant>set PATH=%PATH%;C:\Program Files (x86)\Git\bin
then type,
C:\vagrant>vagrant ssh
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.) - With PuTTY
- 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
Then enter,
C:\vagrant>vagrant 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. - Using Cygwin ssh
$ ssh -p 2222 localhost -l vagrant
C:\vagrant>vagrant suspend
To destroy the VM:
C:\vagrant>vagrant destroy
My environment
- Windows 7, 64-bit
- Vagrant v1.3.5
- VirtualBox v4.3.4
1 comment:
Thanks you so much , was very useful for me (Y)
Post a Comment