outten.net - random thoughts

General Virtual Box SSH Setup

Running a virtual machine is extremely handy for development or trying out different configurations. VirtualBox is handy virtualization software especially since it is free. My goal was to setup a virtual machine to familarize myself with a few different configuration management tools. I could have tried Vagrant, but since we use Centos for most of our servers and Vagrant defaults to Debian, I went ahead and installed Centos myself from a boot.iso.

I wanted to start my Centos virtual machine in VirtualBox and then minimize it. I planned on using ssh to connect from my host machine’s terminal. Since my guest machine was running in NAT mode, I had to tell Virtual Box to forward a port from my host machine to my guest machine. I decided to forward port 2222 on my host machine to port 22 on my guest machine for ssh. From the Terminal, I ran the follow commands:

VBoxManage setextradata "Centos5" "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata "Centos5" "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata "Centos5" "VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/Protocol" TCP

Your VM name “Centos5” could be different as well as the “VBoxInternal…” path. Once this was done, I booted my VM and then I was able to ssh to the guest:

ssh -p 2222 127.0.0.1 

From there, I was able to ssh to my local VM and try out some different configuration management tools.