Download And Run Amazon Linux 2 AMI Locally On Your VirtualBox or Vmware

Shehu Awwal
Shehu Awwal
Published in
3 min readMar 26, 2019

Amazon has already released their custom Amazon Linux for download which is based on RedHat, I would like to walk through anyone interested in using their linux based distros on their hypervisors either Virtualbox or Vmware including WorkStation, Players, Fusion.

Download Amazon Linux 2 For Your Hypervisor Platform

Prepare And Import Amazon Linux 2 On Your VirtualBox

  • Open Your VirtualBox and click on New

Look at the screenshots below, At what I choose, You might decide to use any name your prefer which doesn’t matter.
Name: Amazon AMI Linux 2
Type: Linux
Version: Other Linux (64-bit)

Click On Next, At the Memory Size, Just Click On Next Don’t Worry

At the Hard Disk, Select use an existing virtual hard disk file, and select the location of your downloaded Amazon Linux 2 AMI you downloaded through the link above. And click Add and choose the downloaded file and create.

And Click on Start.

Resetting Your User Account And Root Account Password

This is where things get tricky, As you might know for anyone who has launched an EC2 instance with Amazon AMI Linux2 on AWS, You have to login with SSH Private Keys because of Security, Amazon has already given a way to do that, But it’s a long process doing that, So let’s get started with the process.

By default Amazon Linux has these users,
> ec2-user
> root

  • Start your Amazon AMI Linux virtual machine and while at the grub menu press e which stands for edit at the grub prompt.
  • Look at the line below that ro and change it with
    rw init=/sysroot/bin/sh look at the picture below.
  • This is what I change it to
  • Press Control + x on your keyboard and give it some seconds to enter single mode, This is how it will look like

Okay, Now use the following command to change the root and user password.

:/# chroot /sysroot
:/# passwd root
:/# passwd ec2-user
:/# touch /.autorelabel
:/# exit
:/# reboot

We’re done, You can now use the Amazon Linux 2 AMI on your machine, But there’s one more thing, you can’t SSH because PasswordAuthentication is disabled in the sshd_config by default.

nano /etc/ssh/sshd_config

Look for PasswordAuthentication and change from no to yes, which will look like this.

PasswordAuthentication yes

Then save, After that just.

service sshd restart

If there’s anything you can make use of the comments.

--

--

Shehu Awwal
Shehu Awwal

Hacker — Passionate About InfoSec, Linux, Clouds, Containers, Virtualization, Distributed Systems And Architectures And New Trends.