Sunday, April 3, 2022

Vagrant - Add or Create a Ubuntu 18.04 VM

 Create a VM using Vagrant.


Vagrant is to be installed

Virtual Box is to be installed

Step 1: Goto Vagrant website and Click on Find Boxes Button.

Step 2: In Search Box search ubuntu word and hit enter key.

Step 3: At the bottom, you will find generic/ubuntu1804 and select it.

Step 4: Click on New Tab.

Step 5: Create a folder on your hard drive (C:\VMS\Ubuntu01)

Step 6: Goto command prompt and change directory to C:\VMS\Ubuntu01( cd C:\VMS\Ubuntu01).

Step 7: On the command prompt run the below commands

vagrant init generic/ubuntu1804
vagrant up

Connect to the ubuntu 18.04 vm.

There are multiple ways to connect with vm.

Connect VM using command prompt or command terminal (for mac os)

Step 1: Change the directory where vm is created  C:\VMS\Ubuntu01

Step 2: Run below command to connect with vm on command prompt.

            vagrant ssh

Let's find out the port forwarding for your VM in the virtual box.

  • Select ubuntu vm in virtualbox
  • Click on settings
  • Click on Network
  • Click on Advance
  • Click on Port forwarding button
  • Note down the Host Port number (In my case it is 2222)

Connect VM using Putty.

Step 1: On HostName provide vagrant@

Step 2: In Port enter 2222 ( check the port forwarding steps as mentioned above).

Step 3: Click on open and Accept the connection request.

Step 4: Enter the password as vagrant and hit enter key.

Connect VM using MobaXterm.

Step 1: Download and Install MobaXterm

Step 2: Open Mobaxterm and Click on Session-->SSH

Step 3: Remote Host name:

            specify username: vagrant

             port number 2222

             Click ok button


Post a Comment