If you’re using NAT on your virtual machines, you can make the guest O/S services accessible from the host O/S by doing port forwarding. Obviously, this means that the guest O/S can be accessed by anything on the network which may be good or bad depending on your environment.
Anyway, here’s the excerpt from the VirtualBox user manual:
VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol” TCP
VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort” 22
VBoxManage setextradata “Linux Guest” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort” 2222
That’s 3 different commands with no line breaks in each line.
Replace the “Linux Guest” with the name of your virtual machine - and the ports/protocol if you need to.
I tried it previously in a different order from someone else’s blog post and it didn’t work for me. The order above does seem to work thankfully!
Tags: 22, 2222, forwarding, nat, port, ssh, virtualbox
Leave a Reply