Ssh from one local network to another through inermediary with public IP

StackOverflow https://stackoverflow.com/questions/11828215

  •  24-06-2021
  •  | 
  •  

Вопрос

There is one computer (A) in one local network and the other (B) in the other one. None of them have public ip addresses. Both LAN gateways are out of my control. But I have a VPS server with public IP address and both A and B are able to connect to this VPS. How can I establish an ssh tunnel from A to B using intermediary VPS?

Это было полезно?

Решение

Connect from B to vps forwarding remote port to local side (seem -R ssh option):

B# ssh -R 2222:localhost:22 vpsuser@vpshost

this will connect you to VPS host making port 2222 on server connected to B host port 22 (ssh) Only thing left to do is to connect from A to VPS server and from it to B via 2222:

A# ssh vpsuser@vpshost
VPS# ssh -p2222 buser@localhost
B#
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top