Skip to content

Instantly share code, notes, and snippets.

@hareeshpc
Last active February 19, 2022 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save hareeshpc/fc72b7dc068fe033b503 to your computer and use it in GitHub Desktop.
Save hareeshpc/fc72b7dc068fe033b503 to your computer and use it in GitHub Desktop.
Vagrant installation on Headless ubuntu server (14.04.1) with CentOS and remote ssh login

Installation of virtual box headless

This was obtained from y-yoshinoya at https://gist.github.com/y-yoshinoya/413fcd3f6bfcfce54456

wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian precise non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
sudo apt-get update
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.3 dkms
cd /tmp
wget http://download.virtualbox.org/virtualbox/4.3.20/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack

Install vagrant

wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
sudo dpkg -i vagrant_1.7.2_x86_64.deb

Fetch and run CentOS7 minimal

Other boxes can be fetched at http://www.vagrantbox.es/

mkdir vagrant; cd vagrant
vagrant box add centos7 https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
vagrant init centos7
vagrant up
vagrant ssh

Upgrade the memory and cpu

Edit the Vagrant file with the following

config.vm.provider "virtualbox" do |vb|
  # Display the VirtualBox GUI when booting the machine
  # vb.gui = true
  # Customize the amount of memory on the VM:
  vb.memory = "2048"
  # Change the number of CPUs
  vb.cpus = 2
end

Customise the CentOS to let remote ssh login

config.vm.network :forwarded_port, guest: 22, host: 22222, host_ip: "0.0.0.0", id: "ssh", auto_correct: true

Now you can connect using ssh -p 22222 vagrant@<ip address of host> (default password: vagrant)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment