How to enable ssh to VirtualBox guest Ubuntu

I recently installed Ubuntu Server 12.04 on Oracle VirtualBox and needed to connect to it using ssh. But was wondering how to access my ubuntu server guest from my ubuntu host (yes, I am using ubuntu as host too.) and got it working with few settings. If you want to first install vitrualbox, here is the howto.

This is how I enabled ssh to virtualbox guest:

  1. If the virtual guest is running, first shut it down as we need to change some settings for it.

  2. On the Oracle VM Virtual Manager go to File–>Preferences…

  3. On the VirtualBox – Settings window select Network and click the + sign to add a Host-only Networks. You will see a vboxnet0 on the list now.(If you already have this, you can skip this step)

VirtualBox - Settings-Network

VirtualBox – Settings-Network

  1. Now select the Virtual Machine and click Settings. On the Settings window select the Network. The “Adapter 1” Attached to : NAT is used for internet by the virtual machine, so leave as it is. Select “Adapter 2” and check the Enable Network Adapetr checkbox if it is not already checked. On the “Attached to:” choose “Host-only Adapter” and in “Name:” select vboxnet0(The same we created in the above step.) Click OK.


Ubuntu Server 12.04 - Network Adapter 2-Settings

Ubuntu Server 12.04 – Network Adapter 2-Settings

  1. Now, start the virtual machine guest. Install openssh-server(if not already installed) using the command sudo apt-get install openssh-server.

  2. Edit the /etc/network/interfaces file with the command vi /etc/network/interfaces or with any other editor of your choice. And add the following contents in it if not already there.

auto eth1
iface eth1 inet static

You can see the address is, the 56 is from the vboxnet0. You can check that by following step 2 and 3, and select the vboxnet0 and hit “Enter” key OR right click on vboxnet0 and choose “Edit host-only network”.

Host-only Network Details

Host-only Network Details

  1. Now restart networking using command /etc/init.d/networking restart

  2. Now restart the virtual machine guest.

  3. You can now access your guest virtual machine from host through shh using ssh <username>@ and username can be anything like “root”.

I hope this will help someone and saves his/her day.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :

I am Manohar Bhattarai, a vivid java programmer. I am a keen Linux user. I currently boot Ubuntu Linux. I am a Free/Libre Open Source Software enthusiast.

Posted in Ubuntu, Virtualbox Tagged with: , , , , , , , , , , , ,
3 comments on “How to enable ssh to VirtualBox guest Ubuntu
  1. Tom says:

    Thanks. This worked for me like a charm.

  2. shazu says:

    stuck up with this for configuring my debian on virtualbox. Did follow all ur steps to the core but when I open PUTTY and load the address it says “network error: connection refused”. Have already spent 2 days on this. Firewalls all are unblocked. Ping works both ways(windows 8 host to debian vbox guest and vice versa)

1 Pings/Trackbacks for "How to enable ssh to VirtualBox guest Ubuntu"
  1. […] This occurs because Ubuntu 12.04 uses the PAE kernel by default for 32bit. Hope this helps you all and saves you day. Enjoy Ubuntu 12.04. And if you want to enable ssh access to guest Ubuntu from host, here is the howto. […]

Leave a Reply