4

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.

8

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

  • Thank yo so much – McLan May 30 at 22:41
4

Wikipedia say

On most computer systems, localhost resolves to the IP address 127.0.0.1

your command

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

0

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 127.0.0.1 and for the guest-side 0.0.0.0 as addresses.

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

0

First, make sure that your VM is power-off. Then right-click on VM. Then go to Settings --> Network In the Attached to section, choose Bridged Adapter from the dropdown list. click ok

Now power on the VM Open terminal and type sudo apt-get install openssh-server

Now type ifconfig (if not installed then you have to install it using sudo apt install net-tools) After this command, you will get the ip address like

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.54.375.20  netmask 255.255.128.0  broadcast 10.88.255.255
        inet6 fe80::c5cc:cb0d:b02f:f7f6  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:29:7c:4d  txqueuelen 1000  (Ethernet)
        RX packets 6560  bytes 7484338 (7.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2063  bytes 210479 (210.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Take the ip address from (inet 10.54.375.20) take your address which got displayed.

Now in your host pc (your pc) type ssh username@yourip (eg nitin@10.54.375.20) and you will be asked for your VM password. Once you in you can access your VM command line.

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.