1/31/2014 - 8:43 PM

useful vagrant commands

useful vagrant commands

Install vagrant-vbguest plugin

This installs the plugin that automatically upgrades the virtual machine’s vbox guest additions to match the virtual box version installed on the host machine:

vagrant plugin install vagrant-vbguest 

Here is how you get a basic Centos 6 box:

vagrant box add centos http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box

After that :

cd ~/VagrantImage (or wherever you want the project to be)

Let vagrant create the Vagrantfile in your project directory:

vagrant init centos (this creates the Vagrantfile in the current dir) 

To actually start and use the VM, do :

  1. vagrant up
  2. vagrant ssh

Note : Within the VM, /vagrant will point to the directory containing the Vagrantfile for this VM ( ~/VagrantImage in our example)

To prevent idle ssh connections from timing out (annoyed me)

Set ssh timeouts to a very high number by logging into the VM, and:

su -
vim /etc/ssh/sshd_config
ClientAliveInterval 6000
ClientAliveCountMax 3
service sshd restart