1

I have a remote linux server accessible through SSH only.

My goal is to host multiple Virtual Machines on this host server using VirtualBox. The host server has 1 IP address, so NAT will be used to route to the VMs for example 10022 will forward to server1:22 and 20022 will forward to server2:22.

I have installed VirtualBox and copied a pre-configured CentOS VM to the host server.

I start the VM, but cannot establish a connection to the server for example ssh -p 10022 127.0.0.1 times out.

I've tried many things:

Method 1: Copied existing .vdi, attached to new VM
Method 2: Imported .Ova VM (thought it would help any MAC re-init issues?)

NAT network type, tried natnet1 192.168/16 and 10.0/16
VBoxManage modifyvm "hermes.awoms.com" --natnet1 "192.168/16"

Port forwarding with and without specifying VM ip in modifyvm --natpf1 command
VBoxManage modifyvm "hermes" --natpf1 "guestssh,tcp,,10022,,,22"
VBoxManage modifyvm "hermes" --natpf1 "guestssh,tcp,,10022,192.168.0.15,22"

I can't see if VM is even booting (VBoxHeadless "hermes" --start & runs with no errors) I can't tell if VM is getting an IP address

Is there anything else I can do to get more information from VirtualBox or the VM starting up when the only access I have is SSH?

1
  • Could you please check: 1. If the process of the VM shows some activity during boot. --- 2. If the DHCP server leased an IP address. I guess you refer to a DHCP lease in I can't tell if VM is getting an IP address --- 3. Try to access the leased IP address directly (without NAT). --- 4. Enable serial console in the guest and try to connect over a virtual serial port. Oct 27, 2013 at 8:37

2 Answers 2

1

This should just work.

Your VM might just not be able to complete boot or has an incorrect eth0 network configuration (unsupported NIC, dhcp client not enabled).

I would suggest you to use VRDP (or VNC if you are using OSE) to see what is going on in your VM ( http://www.virtualbox.org/manual/ch07.html / http://www.virtualbox.org/manual/ch09.html#otherextpacks )

1
  • Yep, I didn't realize you could use MSTSC (Windows RDP) with this! It's sitting at an error msg "This kernel requires an x86-64 CPU, but only detected an i686 CPU. Unable to boot - please use a kernel appropriate for your CPU" Oct 28, 2013 at 22:04
0

The attempt to establish a connection by means of

ssh -p 10022 127.0.0.1

is bound to fail: you are trying to connect to the very same machine from which you are issuing the command, on port 10022: this is not what you want. So you do not really know whether the installation is working or not, because your means of communicating with the guest is incorrect.

From your linux server, you can try to contact your guest by pinging it:

ping -c3 10.0.0.15

10.0.0.15 is the default IP address that VBox gives to NAT clients. If that fails, you may try using nmap:

sudo nmap -sn 10.0.0.0/24

This should identify the guest's IP, if you have left defaults in place.

If the guest replies, you may now try to connect to it: from the server,

ssh [email protected]

or whatever the guest IP turned out to be. At this point, you will need to instruct your VM to listen on port 10022 for ssh communications. First, make sure you have downloaded the package containing the ssh server, then edit the file /etc/ssh/sshd_config and change the line

 Port 22

into the line

 Port 10022

Now restart the ssh server, and leave the guest OS.

From another machine in the LAN you may now

ssh -p 10022 myname@IP

where I indicated by IP the IP address of the linux server. This should at least get you started

4
  • 1
    Mark, you (and those who voted up your answer) are misunderstanding how both NAT and port forwarding are working. Have a look to virtualbox.org/manual/ch06.html#natforward
    – jlliagre
    Oct 27, 2013 at 7:02
  • Which part are you referring to, exactly? Ping works, he is not forwarding priviledged ports.
    – user258189
    Oct 27, 2013 at 8:09
  • NAT of loopback addresses (127.0.0.0/8) should be possible. Could you please explain why do you tell something different at the beginning of your post? Oct 27, 2013 at 8:33
  • 1
    @Mark, I'm afraid most of what you wrote is incorrect. ssh -p 10022 localhost should just work. Almost all of your other suggestions should fail (ping, nmap, ssh @10.0.0.15) but 'ssh -p 10022 myname@IP' which might work but only if myname is a valid user in the VM.
    – jlliagre
    Oct 27, 2013 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .