- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools






PC Software

Vargant - How to use Vagrant


What is Vargant

Vagrant is a tool for building complete development environments.

Where do you search Box Files?

Vagrant Cloud



  1. Install VirtualBox

Vagrant Configuration

Change the download location of the box file

Default down load location is C:\Users\user01\.vagrant.d\boxes\.

If you want to change the download destination of the box file, set the environment variable VAGRANT_HOME.

Environment variable :  VAGRANT_HOME
value                : P:\vm_img\.vagrant.d


How to check Vagrant Version

PS C:\Users\user01> vagrant -v
Vagrant 2.1.2

Box Commands

vagrant box add BOXFILE
vagrant box add BOXNAME BOXFILE
vagrant box add IMPORT-NAME
vagrant box add IMPORT-NAME https://xxxxxx/xxxxxx
vagrant box add centos/7 ← download from Atlas
vagrant box add CentOS-6.6-minimal-ja ← Import from local box file
vagrant box add sample
Import box a file
vagrant box list List BOX
vagrant box remove BOXFILE delete box file
vagrant init box
vagrant init centos/7
vagrant init mycentos7
Create Vagrantfile
vagrant package
vagrant package VMNAME
vagrant package VMNAME --output
vagrant package --base NAME
vagrant package mycentos7 --output
Create Box Files. (

VM Commands

vagrant up start VM from Vagrantfile
vagrant reload restart VM
vagrant status List VM with start
vagrant global-status List all VM status
vagrant halt stop VM
vagrant destroy delete VM
vagrant ssh login with ssh

How to use vagrant

Download box and Start Up VM

> mkdir centos7
> cd centos7
centos7> vagrant init centos/7
                                   <-  Vagrantfile is created in this directory.

centos7> notepad Vagrantfile

centos7> vagrant up
centos7> vagrant status

If the specified Box is not registered, it will be automatically downloaded and added to the Box (vagrant box add)
Download to C:\Users\user01\.vagrant.d\boxes\

VMDK files is copied to C:\Users\user01\VirtualBox VMs\

How to Login GestOS

centos7> vagrant ssh
$ sudo su -
  • root password is 'vagrant'.
  • vagrant user's password is 'vagrant'.
centos7> vagrant ssh-config 
Host default
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile P:/vm_img/vagrant/centos7b/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
Allow ssh with password authentication
cp -f /etc/ssh/sshd_config  /etc/ssh/sshd_config.`date -d '1day ago' +%Y%m%d`
sed -i "s/^PasswordAuthentication.*no/PasswordAuthentication\tyes/g" /etc/ssh/sshd_config
sdiff -s /etc/ssh/sshd_config  /etc/ssh/sshd_config.`date -d '1day ago' +%Y%m%d`
systemctl reload sshd

Halt VM

centos7> vagrant status
centos7> vagrant halt
centos7> vagrant status

Delete VM

centos7> vagrant status
centos7> vagrant destroy
centos7> vagrant status

Delete Boxs

centos7> vagrant box list
centos7> vagrant box remove centos/7

Download and use the box locally

Find the BOX file at the following site

For example, in the case of CentOS7, it becomes the following URL.

By adding /providers/ to the end, you can download the box file for virtualbox.

How to Create box file

# ln -s -f /dev/null /etc/udev/rules.d/70-persistent-net.rules
# exit
centos]$ vagrant halt
centos]$ vagrant package


Import my box file

~]$ mkdir centos7a
~]$ cd centos7a
centos7a]$ vagrant box add centos7a
centos7a]$ vagrant box list
centos7a]$ vagrant init centos7a
centos7a]$ vagrant up
centos7a]$ vagrant ssh


Authentication failure. Retrying...

# vargrant up

    default: Warning: Authentication failure. Retrying...

Check Permission

/home/vagrant    700 or 755 or 711
/home/vagrant/ssh    700
/home/vagrant/ssh/authorized_keys  600    

PC Software

software/vargant/index.html.txt · Last modified: 2020/06/09 by admin

Page Tools