ssh between machines behind different routers on the same network

2

I have 2 machines, A and B. Both of them are connected to their own wifi access point (routers). Both the wifi routers are connected to the same private LAN, like a university's intranet.

A's router has its public IP on the private LAN as 10.20.30.40 and B's router has the IP 10.20.30.50. Both A and B have their private IPs (wrt router) as 192.168.0.100. Its obvious that more than 1 machine may be connected to each router, hence the solution should still allow this.

How do I ssh from A into B ?

How do I set up a simple P2P connection between the 2 machines?

Also if there is a 2nd machine on B's router, say C, how do I ssh to it from B? How do I ssh it from A, while simultaneously ssh-ing to B but from a different terminal window ?

Codi

Posted 2015-08-30T10:36:46.080

Reputation: 21

By "a simple P2P connection", do you mean something different from ssh asked about in the previous sentence? If so, what? – bertieb – 2015-08-30T10:46:14.240

Try something like a client and echo-server using P2P – Codi – 2015-08-31T11:54:07.430

Answers

0

First thing you need to do is forward the ssh port (22 by default) on the server side so that when an incoming request on the router arrives, it will forward the request to the appropriate destination.

Then ssh to the public IP of the router (where the ssh server is connected).

In simple words, forward port 22 to the IP of your computer B on the router it is connected to. And use public IP of the router to connect to ssh.

Parth Parikh

Posted 2015-08-30T10:36:46.080

Reputation: 360

0

What is the device that provides connection to both routers?

Use a different local IP range for your router clients so they don't conflict with other devices of the shared network.

Then, if both A and B can ping each others Local IP, then it works the regular way without any port forwarding.

ssh user@local-ip

Bharat G

Posted 2015-08-30T10:36:46.080

Reputation: 524