Lab Configuration

VirtualBox configuration

Quick steps: Create and use an SSH public-private key pair for Linux VMs in Azure.; 4 minutes to read +4; In this article. With a secure shell (SSH) key pair, you can create virtual machines (VMs) in Azure that use SSH keys for authentication, eliminating the need for passwords to sign in.

Install VirtualBox as well as the Oracle VM VirtualBox Extension from Oracle's VirtualBox website:

Double click on the latest Kali *.ova. VirtualBox will start and ask you to import the VM. You can change the name, and make sure to check 'Reinitialize MAC addresses of all network cards'. Then click next untill the end (you can change these settings later).

Once the VM is imported, click on Configuration. Go to the Network tab and create two adapters:

  • Set the first one to NAT
  • Set the second one to Private host only

Repeat for the CTF4 .ova file, but only create one network adapter to Privaate Host only. Again, do not forget to 'Reinitialize MAC addresses of the network card' (in advanced settings of the adapter).

Hyper-V configuration (Windows 10) - NOT WORKING YET


  • Virtual Switch Manager, create a new Internal one and name it Pentest
  • Go to Network and Sharing center -> change adapter settings, select your ethernet or Wifi adapter, right click -> properties.
  • Go to the Sharing tab, check ' Allow other network users to connect through this computer's internet connection' and select the Pentest adapter.

Open Hyper-V Manager

  • Import Virutal Machine
  • Select the folder Virtual Machines from the Kali-Linux-2016.2-hyperv-amd64 download
  • Connect it to the Pentest switch

Then we need to create CTF4

  • New Virtual Machine
  • Name it CTF4
  • First Generation (important, otherwise it won't load)
  • Startup memory 1024, use Dynamic
  • Connect it to the Pentest switch
  • Use an existing virtual Hard Disk, browse to the ctf4.vhdx

Now download a small DHCP server and install it on your host machine. Alternatively, you can also configure a NAT Windows Server image

VMWare Workstation configuration

Start VMWare Workstation, click on 'Open a Virtual Machine', select the Kali Linux file. This will start the VM in VMWare. If you are prompted with 'did you move or copy it', select 'Moved it'.

Then open the settings of the VM, go to Network Adapter and set VMNet8 (NAT). This allows to have your VM on a private network but still provide it with internet access. Your host (your physical computer) will also be able to access this machine, using ssh for example.

Repeat for CTF4 (the VMWare image is in the .wip download), That's it! (Also put CTF4 on the VMNet8).

Configure the Kali VM

  1. Start the VM. On the boot screen (GNU GRUB), select the first option (Kali GNU/Linux).

  2. Enter the default username ('root') and password ('toor')

  3. -- forAZERTY keyboards only -- On the desktop, click in the top right corner on the 'Settings' icon and go to 'Region and language'. Alternatively, you can also press the Windows key and type 'region and language'

    1. In the input sources, add the keyboard 'French'
    2. Once added, remove the US Keyboard. This will allow to boot with a French keyboard when typing your password
  4. Open a terminal and type passwd

    1. Supply your new password
    2. Confirm it
    3. This is now the password used to login to your VM
  5. If you use a High DPI device, it is recommended to run the following command to setup scaling:

  6. Go to the settings again, then Privacy, click on Screen Lock and Disable the Automatic Screen Lock.

Configure the network

By default, DHCP is disabled on Kali Linux.

Add the following lines (press 'i' to go in insertion mode, allowing you to type)

If you are using VirtualBox, also add the following line to configure both networkadapters:

Then press 'Esc' and type :wq to save the changes.In the terminal, type the following command to restart the network service

You should now be connected to internet. Try it by starting Iceweasel and search something on google.

Configure SSH

SSH is a very convenient way to run commands on your Kali Linux machine from a remote host. This is very useful if you use Cmder or CYGWIN on Windows since it has built in ssh support.

Regenerating SSH keys

Kali linux comes with pre-generated SSH keys. It is important to regenerate them, otherwise you would be vulnerable to MITM (Man in the Middle) attacks.Follow the procedure below to regenerate your SSH keys.

Move the default Kali ssh keys to a new folder:

Regenerate the keys:

Compute the md5sum of your new keys

Now do the same for the default keys


Generating A New Ssh Key

Make sure that the hashes are different, otherwise it means you did something wrong.

Configuring the SSH service

Now that we have good SSH key, we need to configure the SSH service.

This will download and install the openssh server. Run the following commands to make it start automatically when your VM boots:

Now, edit the following file:

And set PermitRootLogin to PermitRootLogin yes. Again, press 'Esc' and :wqto write and quit.

Now, very important part, setup your MOTD (message of the day). This is displayed when you will login using SSH from a remote host. Go the following website: and type your welcome message. Then set it as your message of the day by editing the following file. Type 'i' to go in insert mode and paste the content using Ctrl+Shift+v. Don't forget to press 'Esc' and :wq to save the changes.


Once done, restart the SSH service:

Testing the connection

Restart the VM.We can now test the SSH connection from your remote host or Windows Machine. the first thing we need is the IP address of your VM.

You should see two ethernet interfaces: eth0 and eth1. One of them is connected to a local network and has an address that starts with, this is one you should save.

Create New Ssh Key

Now go back to your Windows Host and type the following command in Cmder (replace the xxx by the actual IP address of your Kali VM):

You should be prompted to type your password, type it and you should see your MOTD followed by a prompt [email protected]. This means that you are now connected in SSH on your Kali VM. For convenience, you can create an alias in Cmder to avoid typing the IP address everytime:

Keeping your Kali VM up to date

Fist off, make sure your VM has internet access (depending on what type of virtualization you use, refer to the instructions at the beginning of this guide).

One of the new features introduced with Kali 2.0 is that the distribution now has an auto-update built in. Run the two following commands to get the latest version of the Kali distribution. Note that the second one might take a while.

Additional Tools

You might also want to install a few additional tools that will come handy:

Get Ssh Host Key Fingerprint

Then update you fish.config (vim ~/.config/fish/ and add the following line:

Pre Generated Ssh Host Keys Free

This will get you the Fish shell as well as TheFuck:

Ssh Generate Key Ubuntu

Once this is done, I recommend that you switch back to a private network and take snapshot of your VM, just in case you mess things up later on.

Coments are closed
Scroll to top