SSH to VirtualBox Guest OS

My host OS is Windows 7 Home Premium.  I’m running Ubuntu Server 10.04 on VirtualBox.  This is how I set it up so I can SSH into the guest OS.

The main thing is to modify VirtualBox to forward packets from the host to the guest.  On a Windows machine, the path to VBoxManage might not be set.  If not, you can find it in your VirtualBox installation folder.  My default is: C:Program FilesOracleVirtualBox.

# add new values [1]
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/HostPort” 10022
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/GuestPort” 22
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/Protocol” TCP

VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/nginx/HostPort” 10080
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/nginx/GuestPort” 80
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/nginx/Protocol” TCP

# delete by not specifying the value
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/HostPort”
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/GuestPort”
VBoxManage setextradata “Ubuntu Server 64-bit” “VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/Protocol”

# see existing values
VBoxManage getextradata “Ubuntu Server 64-bit” enumerate

– “Ubuntu Server 64-bit” is your guest OS name in VirtualBox.
– “e1000” name of virtual network adapter: pcnet for PCnet-FAST III, e1000 for Intel PRO/1000 MT Desktop, and so on [2]
– “ssh” is arbitrary name you can use
– “10022” is the host OS’s port being forwarded.  Should be 1024 or higher.
– “22” is the port that the guest OS’s SSH is listening on
– “TCP” is the protocol
Once this has been added, restart the guest machine (close it and restart, not simply reboot) so it can load the new settings.  Voila!  you can now SSH into your guest OS.

sources:
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s