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.

Reset root password in CentOS 5.5

If you don’t know the root password and want to login in to the server, follow these instructions:

Picture 1: Press “e” to edit.

Centos 5.5 VirtualBox Reset root Password

Picture 2: Press “e” to edit.

Centos 5.5 VirtualBox Reset root Password

Picture 3: Type “S” at the end of the line. Press Enter.

Centos 5.5 VirtualBox Reset root Password

Picture 4: After pressing Enter, you will see the following picture. Press “b” to boot.

Centos 5.5 VirtualBox Reset root Password

Picture 5: You will see the following picture…

Centos 5.5 VirtualBox Reset root Password

Type “su –” and you will be a root user.

To make it permanent you should edit it in the following file:

vi /boot/grub/menu.lst
default=0
timeout=5
.
.
.
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 S
.
.
.

Install VirtualBox Guest Additions on Centos 5.5

1. Login as a root user:

su –

2. Go to the Devices->Install Guest Additions…

Install VirtualBox Guest Additions on Centos 5.5

3. Mount Guest Additions device:

mkdir /media/VGuestAdditions
mount -r /dev/cdrom /media/VGuestAdditions

4. Install the following packages:

yum install gcc
yum install kernel-devel
yum install kernel-headers

5. Install Guest Additions:

cd /media/VGuestAdditions
./VBoxLinuxAdditions.run

6. Restart the system:

reboot

Install SQL Developer on Centos 5

Installing SQL Developer on Centos 5 is a little bit different from Installing SQL Developer on Open Suse.

1. Download SQL Developer installation from Oracle SQL Developer RPM for Linux.

2. Install that rpm package:

> su
Password:

# rpm -Uhv sqldeveloper-3.0.04.34-1.noarch.rpm

3. Download JDK from here. You need Self Extracting Installer…not RPM Installer

Go to the directory, where you have downloaded JDK(Note I’ve downloaded file for 64bit…Indicate the correct filename):

> su
Password:

Make it executable(indicate correct filename,which you’ve downloaded):

#chmod a+x jdk-6u26-linux-x64.bin

Run that file:

# ./jdk-6u26-linux-x64.bin

There will appear folder jdk1.6.0_26. Copy that folder to the desired location, you will need it.

4. Open the .bash_profile(located in $HOME directory) and add/edit the following entries:

JAVA_HOME=/usr/java/jdk1.6.0_26/
PATH=$PATH:/opt/sqldeveloper/
export PATH
export JAVA_HOME

5. Run SQL Developer:

# sqldeveloper