I used autossh in my raspberry pi to connect to one of my VPS.
But I have 4 raspberry-pi(s). I used the same script to connect to my remote VPS, so that I can login in every raspberry pi anytime remotely.
For those 4 pis, I used autossh
in this way:
add this line to my /etc/rc.local
on my 1st Pi.
sudo su pi -c "autossh -M 1122 -4 -NC -R \*:8822:localhost:22 [my_vps_username]@[my_vps_IP] -p 22" &
So I can use
ssh -l pi [my_vps_IP] -p 8822
to connect to my 1st Pi.
If I want to connect to the 2nd Pi, I have to change the port to be 8823 or something.
sudo su pi -c "autossh -M 1122 -4 -NC -R \*:8823:localhost:22 [my_vps_username]@[my_vps_IP] -p 22" &
Here's the question:
How to have lots of SSH reversing connections without specifying port one by one?
I may have 100 Pi(s) and I need to connect to them via SSH anytime when powered on. To get rid of port duplicating, and manage those SSH connections systematically.
Appreciate!