0

I'm practicing to use the ssh command with two computer on a local network. From the 192.168.102.77 machine to 10.0.2.15 machine, SSH worked well. However, the inverse is not true, i.e., from the 10.0.2.15 machine to 192.168.102.77 machine, SSH didn't work well. Honestly, I don't know how to fix this problem. Could anyone be able to tell me how to enable this access with the ssh command?

P.S. 10.0.2.15 is a VM on a MBP and 192.168.102.77 is ip address of another MBP with Ubuntu OS.

[jeremie@my_account] ~ ❯ ssh -vvv 10.0.2.15                         
OpenSSH_7.3p1 Ubuntu-1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "10.0.2.15" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 10.0.2.15 [10.0.2.15] port 22.
debug1: connect to address 10.0.2.15 port 22:
Connection timed out ssh: connect to host 10.0.2.15 port 22:
Connection timed out

For the sudo lsof -inP, I got the following picture :

enter image description here

Interesting question : Do I have modify the network from VirtualBox of my VM of a certain way?

  • The IPs look like they are from different networks. If it is an organization, you may need to contact the IT department. – mikewhatever Dec 09 '16 at 20:16
  • 10.0.2.15 is a virtual machine on a macbook pro. I used hostname -I command and I got those IPs. Therefore, I simply applied ssh on those IPs for the respective machine – Sandra Ross Dec 09 '16 at 20:17
  • Make sure that ssh server is installed on the VM OS, and verify it is up and listening: sudo lsof -i -n -P. Also, you said "From the 192.168.102.77 machine to 10.0.2.15 machine, SSH worked well", but the output shows it backwards. Which is it? – mikewhatever Dec 09 '16 at 20:28
  • @mikewhatever To be clear, when I indicated ssh 192.168.102.77 in the virtual machine, it worked well, but not the inverse. BTW, I modified the question. – Sandra Ross Dec 09 '16 at 20:36
  • I think they're not working because they don't look like they're on the same network range – answerSeeker Dec 09 '16 at 20:54
  • 1
    What type of network adaptor is your virtualization software using? This looks like it is a virtual NAT designed to allow the VM to make outbound network connections but not (without configuration in the VM manager, not the host or the guest) receive inbound network connections. – user4556274 Dec 09 '16 at 20:54
  • @TatakaiWasumi What do you mean exactly? Do you have an idea how to fix this issue? – Sandra Ross Dec 09 '16 at 20:55
  • Can you change your vm ip to be on the 192.168.102.1 network? The vm needs to be as if it's part of the lan – answerSeeker Dec 09 '16 at 20:56
  • @TatakaiWasumi No problem, but how could I change the ip address of my virtual machine? – Sandra Ross Dec 09 '16 at 20:58
  • http://askubuntu.com/questions/470237/assigning-a-static-ip-to-ubuntu-server-14-04-lts You can use nano or gedit for editing. It's easier than vim – answerSeeker Dec 09 '16 at 21:00
  • Probably a stupid question, but your host does have the ssh-server installed and running, right? – Caturday Saint Dec 09 '16 at 21:11
  • @ServiceManager Yes – Sandra Ross Dec 09 '16 at 21:12

2 Answers2

1

Given the IP, I would suspect the issue is the host machine doesnt know how to route traffic to 10.0.2.15? When initiating a SSH session from 10.0.2.15, the traffic is directed (routed) to the 192.168.102.x network by default.You can test this theory by trying to ping the 10.x.x.x machine from the 192.x.x.x machine, if it says something like network unreachable you have your answer.

In this instance a potential solution would be to amend the VM to have an address on the 192.x.x.x network, you should then be able to perform SSH from either machine.

1

I got the same problem earlier this week. The right way for you to use the ssh command on a virtual machine is to configure your virtual machine's network from VirtualBox as follows:

enter image description here

In fact, as @RichardRose and @TAtakaiWasumi pointed out, using ssh command on a VM needs to have an ip address similar to 192.168.x.x. I'm not an expert, but I read something related to this at a given time.

Hope it'll work!

  • Oh yes, it works perfectly!!!! – Sandra Ross Dec 10 '16 at 01:33
  • @SandraRoss: I am confused. You accepted this answer and added a comment that it works perfectly. yet you now have another question that seems to suggest that you do not have a proper bridged connection to your VM. I can not speak for others, but myself, I need some clarity. – Doug Smythies Dec 10 '16 at 19:31
  • I don't know why, but I was located in a library yesterday and that technic worked perfectly. I've succeed to get an 192.168.x.x on the virtual machine. However, I'm now in a cafe, and this technic is no longer working (and I don't know why). – Sandra Ross Dec 10 '16 at 19:37
  • @SandraRoss It will be simpler if you test this solution on your home network, because the configuration of any other network may be unknown. – wjandrea Dec 11 '16 at 03:44