Skip to content

Instantly share code, notes, and snippets.

@mtthlm
Last active January 3, 2016 03:39
Show Gist options
  • Save mtthlm/8403494 to your computer and use it in GitHub Desktop.
Save mtthlm/8403494 to your computer and use it in GitHub Desktop.
How to setup a CentOS 6.4 x86_64 virtual machine in VirtualBox for Vagrant

This guide is a compilation of resources (#1, #2) provided by Vagrant, and assumes you already have a fresh install of CentOS 6.4 x86_64 (1 Core/512MB RAM/12MB Video RAM/8GB Dynamic Drive/NAT Network/No audio or USB) with a root password of vagrant.

Step 1: Update openssh-server and sudo

$ yum update openssh-server sudo

Step 2: Edit /etc/ssh/sshd_config

Change #UseDNS yes to UseDNS no

Step 3: Edit /etc/sudoers

  • Comment out Defaults requiretty
  • Add Defaults env_keep += "SSH_AUTH_SOCK" to the end of the Defaults env_keep section
  • Add vagrant ALL=(ALL) NOPASSWD: ALL to the end of the file

Step 4: Add vagrant user

$ useradd -m vagrant
$ echo vagrant | passwd vagrant --stdin

Step 5: Setup public key for vagrant user

$ mkdir /home/vagrant/.ssh
$ curl -k https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub > /home/vagrant/.ssh/authorized_keys
$ chown -R vagrant:vagrant /home/vagrant/.ssh
$ chmod 0700 /home/vagrant/.ssh
$ chmod 0600 /home/vagrant/.ssh/authorized_keys

Step 6: Clean yum caches

$ yum clean all

Step 7: Shutdown, and create vagrant box

$ shutdown -h now
$ vagrant package --base <name_of_virtual_machine_in_virtualbox>

Optional Step: Install Puppet

$ rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm
$ yum install puppet
$ puppet resource service puppet ensure=running enable=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment