Accessing SSH when multiple RPis are connected to the router

So, I have multiple Raspberry Pi 4Bs (8) connected to my FritzBox via ethernet cables. All Pi's have SSH activated in their settings and are SSH-able within the local network by typing "ssh pi@ip.adress". I set up a dynDNS service for my router, so i can reach it without having to know the exact IP adress. That worked fine too.

Then I used the "Permit Access" option of the FritzBox to forward port 22 and 3389 to one of the RPi's. Now I can use SSH and MS Remote desktop on that one.

Problem: All the other RPi's have headless Raspberry OS Lite installations and I also need SSH from the Internet for them. But since the first RPi is already using port 22, i can't use any other RPi's with port 22.

There is a method called port-redirecting I read about multiple times in the internet. But noone really explained that one easily. So, i have to find a way to do this:

Router

|-> external port 2200 -> port 22 of Pi Nr. 0

|

|-> external port 2201 -> port 22 of Pi Nr. 1

|

|-> external port 2202 -> port 22 of Pi Nr. 2

|

|-> external port 2203 -> port 22 of Pi Nr. 3

But i have no idea how that works ;D

Which config file do I have to edit on the RPi's or which settings do I have to change on the router to achieve this?

Thank you for an answer :)

(PS: I am a networking noob. I have been coding java software for pc's and sometimes Discord Bots as a hobby for about 2 years now. But i have no idea how all that internet stuff works and i wanna learn it XD)



Read more here: https://stackoverflow.com/questions/68473648/accessing-ssh-when-multiple-rpis-are-connected-to-the-router

Content Attribution

This content was originally published by Jasha Grüner at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: