SSH into VirtualBox on Mac

hadooplinuxsshvirtualbox

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 127.0.0.1 port 2222: Connection refused":

ssh root@127.0.0.1 -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.

Best Answer

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

At Ubuntu 18.04 additionally install ssh and reboot

sudo apt-get install openssh-server
Related Question