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?

12
  • The IPs look like they are from different networks. If it is an organization, you may need to contact the IT department. Commented Dec 9, 2016 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 Commented Dec 9, 2016 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? Commented Dec 9, 2016 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. Commented Dec 9, 2016 at 20:36
  • 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. Commented Dec 9, 2016 at 20:54

2 Answers 2

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!

4
  • Oh yes, it works perfectly!!!! Commented Dec 10, 2016 at 1: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. Commented Dec 10, 2016 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). Commented Dec 10, 2016 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
    Commented Dec 11, 2016 at 3:44
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .