Sunday, May 24, 2015

How to setup SSH access between Host and VirtualBox Guest VMs

1. Make sure you have SSH server running in your VM

For example in my Ubuntu
sgeevar@ubuntu-ws:~/share$ service ssh status
ssh start/running, process 1157

If you do not have it, install using:
sudo apt-get install openssh-server

2. Power off your VMs and go to VirtualBox
File > Preferences > Network > Host-only Networks

See if you already have an entry, if not create one.

3. Open your VMs settings
Settings > Network > Adapter 2

Check Enable Network Adapter
Attacked to: Host-only Adapter
(The entry you saw in step 2 will be automatically assigned to Name)

Save the changes and exit

4. Now open a terminal in your Host machine
Give ifconfig (ipconfig if Windows)

You should see a new entry corresponding to the host-only adapter we created
Note down the inet addr (in my case 192.168.56.1)

5. Now boot your virtual machine
sudo vim /etc/network/interfaces

Add these entries
auto eth1
iface eth1 inet static
address 192.168.56.56 #based on the address you noted in step 4
netmask 255.255.255.0

Save and exit

sudo ifup eth1

Thats all, now you should be able to connect to your VM via SSH (like putty)

username@ipaddress

Sunday, May 3, 2015