Configuring SSH access for VirtualBox Host to Guest

I have installed VirtualBox with CentOS. I’ve decided that it would be easier to connect VBox from Host terminal via SSH then using Vbox GUI environment. I’ve found this process a little bit difficult and fortunately have solved it.

Now, I want to share my knowledge with you:

Note: <VBoxName> will be the name of the Virtual Box Machine. To find it type command “hostname” on guest machine.

1. Open up the terminal window on Host machine, and run the following:

$ VBoxManage setextradata <VBoxName> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort” 2222

1. 1 If you encounter the following error(if not ignore this section),

VBoxManage: error: Could not find a registered machine named “VBoxName”...
do the following:
$ VBoxManage createvm –name <VBoxName> –register



$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort” 2222


$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort” 22


$ VBoxManage setextradata <VMname> “VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol” TCP

5.  Close the guest Machine Window (reboot is not enough)

Open up the terminal window on Host machine and run:

$ ssh -l username -p 2222 <localhost>

Where <localhost> is the name of the Host machine.

6.1  If you get the following error(if not ignore this section):

ssh-exchange-identification connection closed by remote host

One of the solution is to start ssh on both HOTS/GUEST machines:

$ /etc/init.d/sshd start

7. That is all, and one more hint: username by which you want to connect to the Guest machine must have password.

About Mariami Kupatadze
Oracle Certified Master Linkedin:

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

%d bloggers like this: