I have a Raspi that I want to access on my vacation home. It's on a local network behind a CGNAT router (that is, with no possibility to forward ports on the router) but since it has internet access, I have set up a reverse tunnel to a second Raspi on a local network at home. This second local network is connected to internet through a router with port forwarding capability. The setup as well as the sequence to follow to connect to the remote Raspi can be visualized on the image enclosed: enter image description here

This setup works fine, but it implies ssh access from A to Raspi B, and from B, to shh to Raspi C (the remote one).

Trying to get rid of the need to login on common server B, I have setup a second schema forwarding port 22 from B to C, so as to be able to ssh directly from A to C:

enter image description here

However, there is something wrong with this second approach because I cannot ssh to C directly from A. I realize that the problem comes from redirecting port 22 in B and C which is the same port used to setup the reverse tunnel, but I do not see how to redirect ports so as to be able to ssh directly from A to C.

Any idea of how to do this ?

Thanks and best regards

1 Answer 1


It seems you can listen on multiple ports with sshd (and also it should be doable with 2 instances of sshd).

But personally for your setup I'd prefer a VPN with proper routing !

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 17, 2023 at 14:52

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