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

 

2.

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

3.

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

4.

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

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


6.
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.

Advertisement

About Mariami Kupatadze
Oracle Certified Master Linkedin: https://www.linkedin.com/in/mariami-kupatadze-01074722/

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: