VirtualBox Shared Folders + SSH from OSX Host to Ubuntu Server Guest Tutorial

Image for post
Image for post

VirtualBox is a powerful virtualization product that allows an unmodified operating system with all of its installed software to run in a special environment, on top of your existing operating system. Since I became a full time independent software developer, I have frequently found myself working on very different software environments. VirtualBox has helped me to setup an environment for each of my clients and easily manage them.

In this tutorial, I will show you how to setup a virtual machine instance with shared folders and SSH from your host to the guest. This tutorial assumes you have already setup an Ubuntu server virtual machine.

SSH from Host into Guest Machine Setup:

SSH is a protocol used to securely log onto remote systems. It is the most frequent way to access remote Unix-like servers.

Instructions:

| Name | Protocol | Host IP | Host Port | Guest IP | Guest Port |
|------|----------|---------|-----------|----------|------------|
| SSH | TCP | | 2281 | | 22 |
sudo apt-get update
sudo apt-get install openssh-server

Shared Folders Setup:

Shared folders provide an easy way to exchange files between the host and the guest machine. This means you can access and modify your local files with your favorite tools and still run the server and its dependencies on your virtual machine.

Instructions:

sudo su
apt update
apt upgrade
apt-get install dkms build-essential linux-headers-generic gcc make
mount /dev/cdrom /mnt
cd /mnt
sh ./VBoxLinuxAdditions.run
reboot

Setting up the shared folder:

# 'folder_name' = given in the shared folders configuration
# 'path/to/shared/folders' = guest path to access the shared folders from
sudo mount -t vboxsf -o uid=1000,gid=1000 shared_folder_name path/to/shared/folders

Conclusion

I hope you found this tutorial easy to follow and useful. I have also been reading a lot about Vagrant, as it seems to be another popular choice by developers. I plan on giving it a try in the following months, and will let you know my opinion about it. If you have any questions or suggestions, feel free to leave a comment below.

Written by

Experienced and detail oriented software developer with solid knowledge of Ruby & JavaScript with over 5 years of experience building user-focused products.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store