1

I was trying ssh hands-on and was trying to connect to a Ubuntu guest 14.04 on VirtualBox from a Ubuntu 14.04 host. I had opened port 22 in both the endpoints and tried the ssh command. I got a "no route to host" message. May I know how to diagnose this?

1

It depends on how you have set up networking in Virtualbox between the host and the guest. The two most common set-ups are NAT or Bridged.

In the NAT (Network Address Translation) case you will have to set up port forwarding to access the guest from your host. AFAIK, this is the default for Virtualbox and you will likely be using that if you have not changed the network settings when you creted the VM (Virtual Machine).

Setting up Port Forwarding is not difficult, but how it works is more difficult to understand than using Bridged. In NAT mode, the guest uses the IP address of the host.

The easiest is to use Bridged. You have to set this up when the virtual machine is turned off. Go to the Network tab in Virtualbox for the VM and set the Attached to: field to 'Bridged Adapter' and start the VM.

In Bridged mode the VM gets its own IP address on your network (via DHCP).

After the VM has started, log in and give the command ifconfig in a terminal window. This should give you the IP address of the guest machine.
You can then SSH from your host to the guest: ssh <username>@<guest IP>.

Alternatively, after the VM has started, log in give the command hostname in a terminal window. This should give you the hostname of the guest machine.
You can then SSH from your host to the guest: ssh <username>@<hostname>.

You can omit username@ if you want to ssh using the same username as on your host.

  • If bridge is not possible, one can also create an additional host-only interface for communication between the guest and the host, in addition to a NAT one for Internet access. – fkraiem Jun 26 '16 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.