0

I am not much experienced with ubuntu servers and ssh connections, but I would like to allow ssh connections in a ubuntu machine. I am trying to connect (ssh) to this ubuntu machine (which I setup in a virtual machine). That's the server status:

enter image description here

And these are the host info:

enter image description here

However I am unable to establish a connection:

ssh -X sudoname@10.0.2.15

ssh: connect to host 10.0.2.15 port 22: Connection timed out

I guess I am missing something and I would be glad for any help.

0

In the VirtualBox > Machine > Settings > Network > Adapter 1

Select Attached to: Bridged Adapter and the name of your network card (it's probably already selected)

0

First Method:

USING BRIDGED ADAPTER

  1. Setup your SSH in the host machine:

    • Open your terminal and run this command to set up ssh properly:

      ssh-keygen -t rsa -b 4096 # generates ssh key so others know you, add values, but leave the default setup location
      ssh-add   # adds it to the client
      
  2. Using Network Bridged Adapter settings:

    • Go to the Settings --> Network choose the device name, in my case eth0
    • Choose Bridged Adapter for option Attached to

      enter image description here

    • Note: no need to switch off or shutdown the VM it will pick up the new settings
  3. Go to your Ubuntu virtual machine from the terminal run:

    ifconfig
    
    • look for the IP address associated with the network device (not lo device)
  4. Now back in the host machine connect to Ubuntu virtual machine using the IP gotten in step 3:

    ssh -l <user_name_of_vm_user> <IP_address> #OR
    
    ssh <user_name_of_vm_user>@<IP_address>
    

Second method:

USING NAT ADAPTER

  1. Setup your SSH in the host machine:

    • Open your terminal and run this command to set up ssh properly:

      ssh-keygen -t rsa -b 4096 # generates ssh key so others know you, add values, but leave the default setup location
      ssh-add   #adds it to the client
      
  2. Using Network NAT Adapter settings:

    • Go to the Settings --> Network choose NAT (which is the default)
    • Select Advanced option
    • Select Port Forwarding
    • Add the following to the table that appears:

      • Name: any name you like
      • Protocol: leave as is or change
      • Host ip: ignore
      • Host port: any number say 3003 (but not one already being used in host)
      • Guest ip: ignore
      • Guest port: 22

      • enter image description here

      • enter image description here

    • Note: no need to switch off or shutdown the VM it will pick up the new settings
  3. Now back in the host machine connect to Ubuntu virtual machine using the IP gotten in step 3:

    ssh -p 3003 -l <user_name_of_vm_user> 127.0.0.1 #OR
    
    ssh -p 3003 <user_name_of_vm_user>@127.0.0.1
    

Note:

Free ports chosen if using firewall both on host and guest

Virtualbox Networking

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.