I'm new to Linux and I'm trying to ssh from one computer to another.

I have two computers:

Computer A is running Windows 10 with VirtualBox running Ubuntu Server 18.04 LTS

Computer B is running Ubuntu 18.04 LTS

Both computers are connected to my home router via Wi-Fi

I want to ssh into the VB Ubuntu server from computer B and I've having trouble.

VB Global Tools > Host Network Manager settings:

DHCP Server: Enable

Adapter: Configure Adapter Manually with IPv4 Address: 192.168.56.1 and IPv4 Network Mask: 255.255.255.0

Network Setting:

Enable Network Adapter: checked

Attached to: Host-only Adapter

Name: name of the adapter

VB Ubuntu Server's ssh and ssh-server is installed and running. service ssh status indicates the service is active and it's listening on port 22. Just to verify that ssh is running fine, I'm able to ssh into VB Ubuntu guest from host using port forwarding method and ssh name@localhost or ssh name@127.0.0.1

I assume the port forwarding method is not the solution if I want to ssh from one computer to another; just host to guest (I've tried this method out of desperation and I get the Connection refused error)

Back to the Host-only Adapter method. After doing a ifconfig on the VB Server, I see my new IP address and tried to ping this address from the other computer and get the error:

Time to live exceeded

If I do ssh name@ip I get

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

What do I need to do to be able to ssh into the VB Ubuntu Server from my other computer?

Thanks

  • How about selinux and firewall... – SivaPrasath Jun 10 at 18:16
  • @SivaPrasath not sure what selinux is but if you could elaborate. Firewall on the router is set to allow ping and LAN to WAN, WAN to LAN are set to: Allow all. Windows firewall is on for Domain, private and public network. – Chairman Meow Jun 10 at 18:26
  • @ChairmanMeow Not the Windows firewall but the firewall for Ubuntu Server which is what you're trying to ssh to. On Ubuntu Server run firewall-cmd --permanent ---zone=public --add-port=22/tcp and then firewall-cmd --reload. That will open port 22 but to be sure, run firewall-cmd --list-ports and you should see port 22. Also, run netstat -tanp | grep 22 and that should show ssh listening on port 22. To rule out selinux, open /etc/selinux/config with a text editor and change the line that says SELINUX=enforcing to SELINUX=disabled, reboot, and try again. – Nasir Riley Jun 10 at 18:48
  • have you installed the ssh daemon? – Rui F Ribeiro Jun 10 at 19:37
  • @NasirRiley ssh is listening on port 22. However, when I nano the selinux conf file semanage.conf, I don't see the line SELINUX=enforcing and there are no other conf file under /selinux directory. – Chairman Meow Jun 10 at 19:45
up vote 2 down vote accepted

It is because you have your VM set to "Host only" for the network type. This creates a virtual NIC for your host OS and sets up a private subnet, allowing host to VM communication but that is it.

You want to set up your VM as "Bridged" network - this will attach it to the host's NIC and let your router give your VM an address via DHCP. It will be just like any other computer on your network.

Note that in some corporate/school environments as well as hotels, conference centers, internet cafes etc, some setups will block multiple IPs on one "port" or block multiple MAC addresses behind one "port".

  • Thank you so much, switching to "Bridged Adapter" worked! – Chairman Meow Jun 10 at 20:22

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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