Accessing a virtual machine via SSH connection
Remotely accessing a device or server using SSH connection requires that this other device or server exists. If it does not, there is still a way to achieve this with the help of a virtual machine. The idea is that a computer (the host) will remotely access via SSH another computer (the guest), the latter being a virtual machine (VM); meaning that practically, both host and guest are running on the same machine.
In the example below, host runs Windows 7, guest runs Ubuntu 14.04 using VirtualBox. It is assumed that the VM has already been created in VirtualBox.
1. Set up the Network of VirtualBox to bridged adapter.
In Settings > Network > Adapter 1 then select "Bridged Adapter" for the field "Attached to".
The bridged adapter mode will allow the host and the guest to have different network interfaces. It is like the two are connected with a network cable and they can send data to each other through this network.
2. Start the VM.
3. In Ubuntu, install SSH server to be able to use this type of connection.
sudo apt-get install openssh-server
4. Check what your guest's IP address is by running:
ifconfig
The guest's IP address is the "inet addr" of "eth0". This is the IP that will be used to establish the SSH connection.
5. On your host, run Putty and enter the guest's IP address to establish the connection.