Then restart the SSH server: service ssh restartįinally, we can log out as the root user, by typing: exit Optional step: To speed up SSH connections to the virtual machine we need to modify the SSH server configuration also: cd /etc/sshĪdd this line to the end of the file and save it: UseDNS no If everything was done correctly this is how the folder structure of /home/vagrant and /home/vagrant/.ssh should look like including the permissions. OpenSSH is very strict about this folder and file permission, so let’s change it to the correct one: chmod 700. Just run the following command to get it directly: wget -O. Vagrant uses an insecure keypair to connect to the virtual machine, which you can download here: /mitchellh/vagrant/blob/master/keys/vagrant.pub Still logged in with the root user go to the vagrant user’s home directory: cd /home/vagrant
We need to set this up for our vagrant user. In order for Vagrant to be able to SSH into the virtual machine, it uses public key authentication.
To set this up type in the following command as the root user and type in the password when prompted: passwd Just type: visudoĪdd the following line to the end of the file and save it: vagrant ALL=(ALL) NOPASSWD:ALLĪ general guideline when creating Vagrant boxes is to set the root password to a well known one. To set this up we need to run the visudo command to configure password-less sudo for the user. Vagrant requires a couple of specific options to be set in order to play nice with the virtual machine.Īll of the operations carried out by Vagrant will use the vagrant user and all of the sudo commands need to execute without asking for a password each time they are ran.
Using the root user, update to the latest packages by typing the following commands apt-get updateĪpt-get upgrade Configuring the virtual machine for Vagrant For a development machine, security isn’t paramount anyhow. Note that this is not a very secure setup, and securing Ubuntu is out of the scope of this article. Next, switch to the root user by typing: sudo su. Use the vagrant user and password to do so. This should sum up the installation, next you’ll be prompted to log in.
Select to install GRUB boot loader on the master boot record.
When prompted which software to install, select OpenSSH server, the rest such as LAMP or MySQL will be installed later.Partitioning method: Guided – use entire disk and set up LVM.On the timezone panel, select UTC or your own preferred timezone.For both the username and password also type vagrant.When prompted to enter the hostname, type vagrant.I will be touching on the more important ones below. There are a couple more steps in the installation process such as selecting the language, country, etc. Now we are ready to fire up the virtual machine and install Ubuntu as the guest OS.
On the Controller: IDE click on the little CD icon (highlighted in red in the image below) then click Choose disk and select the Ubuntu ISO file. Select the virtual machine from the list, click Settings and click on the Storage tab. It’s just like how you insert a bootable CD into a CD-ROM. You need to insert the downloaded Ubuntu 14.04 LTS ISO file as a virtual CD, so upon starting the virtual machine the operating system gets installed. Click continue and your virtual machine is almost finished. On the Storage on physical hard drive pane select Dynamically allocated and set a minimum of 8 GB. On the next pane, select Create a virtual hard drive now then select VMDK (Virtual Machine Disk). If you install an LTS version today, you’ll get updates up to five years from now.įor web development, it’s always best to use an LTS tagged Ubuntu and the good news is that the Ubuntu 14.04 LTS was released on April 17th, 2014, therefore support lasts until 2019.Īfter the ISO file finishes downloading, fire up VirtualBox and click on New to create a new virtual machine then select Linux as the type, Ubuntu (64 bit) as the version and give your virtual machine a name.Ĭlick continue, set the memory size to 1024 MB or higher if you think you will have memory intensive tasks running in the virtual machine. The LTS timespan stretches to five years. LTS stands for long term support and it’s given to a specific subset of Ubuntu versions. Next, head over to the Ubuntu download page and grab the Ubuntu 14.04 LTS ISO.Ī new version of Ubuntu is released in every six months and support for each version is limited. You need to install VirtualBox first before creating the virtual machine. Although Vagrant doesn’t discriminate over which provider to use, we’ll be using VirtualBox in the examples below. To create a virtual machine, you need a virtualization provider. Note: for the examples below, you will need to have at least Vagrant version 1.5 installed on your local computer.