How to forward port into VirtualBox or How to connect with guest virtual machine via ssh

Published by Igor Khrupin on

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 how 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
That’s all


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.