Let me describe my task.
I have installed Linux Ubuntu Server in my VirtualBox. I use this virtual machine for some experiments. I don’t want do some tasks on my physical PC.
To connect with this Virtual Machine I want to use SSH.
It can be done via forwarding physical PC port in Virtual Machine.
Here is ho to do this.
Run this commands in terminal:
$ VBoxManage setextradata "YOUR_VM_NAME" \ "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP $ VBoxManage setextradata "YOUR_VM_NAME" \ "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22 $ VBoxManage setextradata "YOUR_VM_NAME” \ "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
Replace pcnet with e1000 if you are using Gigabit adapter
Now if you connect to your PC via ssh with 2222 port you will forwarded in Virtual Machine
ssh -p 2222 hudson@localhost
Where hudson – username on Virtual Machine