How to Connect to a Virtualbox VM Via SSH (Part 2)

Continued from Part 1. Next, you need to configure Virtualbox to appear on your network. You can do this by using a second virtual network device. Do the following:

  1. Click File…Preferences
  2. Choose “Network” and add a new device if one is not already present by click the green plus.
  3. You should then have a device called vboxnet0 or something similar. Click OK to confirm.
  4. Select your virtual machine from the list and click the Settings button
  5. Click Network and select the “Adapter 2” tab
  6. Check the box to enable the network adapter
  7. Select “Host Only Adapter” from the drop down menu
  8. Choose “vboxnet0” from the second drop down menu
  9. Click OK

In your virtual machine, you should now be able to determine your IP address by looking at the settings for your second adapter. From the command line, type:

# ifconfig

You can use that IP address to connect to any remote services, including SSH, web server, database, etc. You may need to configure your virtual machine’s firewall to allow them access. Your remote services will behave just like live services, even though they are running through a virtual machine. This gives you the ability to run any types of tests you want or even run a full website from within it.