I just installed VirtualBox on my mac, created a new Ubuntu Virtual Machine with "Use an existing virtual hard disk file" of the Cloudera Hadoop disk image. I'm able to start and run the virtual machine, however, I'd prefer to ssh into from my terminal. The following produces the message "connect to host port 2222: Connection refused":

ssh root@ -p 2222

I've also tried -p 22

I've also tried using "cloudera" as the user. Is there a VirtualBox setting I need to change to allow SSH?

I've also just tried to create a new linux virtual machine without using Cloudera disk image, and I can SSH into that either.


I have a Mac on which I had installed VirtualBox.

So this is what worked for me ...

Click on the cloudera image and click settings Click on Network -> Adapter 1(by default have attached to as NAT) -> Advanced -> Port Forwarding Add a new entry (click on + to add) with the following settings:

Host Port: 1111, Guest Port: 22, leave the host IP and guest IP blank

Connect from your Mac cmd shell using the following ssh -p 1111 cloudera@localhost


Wikipedia say

On most computer systems, localhost resolves to the IP address

your command

ssh root@ -p 2222

Try to connect from mac to your mac and not to your VM.

Try to find the address of your VM and change your command acordingly.

NB: if you just want to ssh from your mac to your VM you can add a "host-only" network adapter to your VM.

`ifconfig -a`

in your ubuntu VM should then show you the ip-address associated with vboxnet0 that you can use for connexting from your mac.


If you worked only with a provided harddisk-file, this implies for me that you created the VM yourself. The default network-setting for new VMs is "NAT" so you have to create a NAT-Rule, routing the host's port 22 to the VM's port 22.

I don't know about MacOS, but under Linux, you'd have to use a port > 1024. I usually use ports starting with 10000 and the respective service-port. In your case, I'd make a port-mapping of 10022 -> 22. For the entry in the "host"-column I use and for the guest-side as addresses.

You get to the menu via "Right-click on VM" in VirtualBox Manager -> "Change" -> "Network"-tab -> "Port-Forwarding"

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.