Port Forwarding for SSH & HTTP on VirtualBox

Thilina Ashen Gamage
Platform Engineer
Published in
4 min readMay 6, 2018

--

When we do software emulations in custom environments for testing and experimental purposes, we often depend on a Virtual Machine (VM) option like Oracle VirtualBox or VMWare, rather than using physical machines or cloud-based clusters. In general, a VM acts as a separate physical computer which resides inside our host computer consuming a proportion of host machine resources such as RAM, Storage, Display, Network etc.

Each VM has its own OS environment and can work independently as a separate physical machine. But mostly we only need the terminal access to execute some bash scripts and get our work done using the programs running on these VMs. Also if we can emulate the VM in headless mode (no GUI) by installing the server version of our preferred OS distribution, we can minimize the overall hardware footprint too.

On Oracle VirtualBox, we can let our VM work as a server in headless mode and login to it from the host machine to perform operations via SSH or even serve a web app through VM and view it on the host’s web browser. Let’s see how we can configure these settings.

Configuring SSH

SSH is a secure network protocol widely used for remote login to a computer system by its privileged users. Let’s configure SSH access to guest system from our host machine with the following steps:

01) Start the guest VM and install openssh-server on guest machine. If you are on a Debian/Ubuntu VM, you can follow with my terminal…

--

--

Thilina Ashen Gamage
Platform Engineer

Advocate of Cloud, Microservices, & Clean Code | 1.5M+ Reach | For more exciting content, stay in touch: https://medium.com/@ThilinaAshenGamage