I am looking for a solution that would let me remotely access multiple devices from a central server.
The devices are preinstalled with custom software but their network conditions will be unknown and probably under 3G or NAT restricted WiFi environments.
The first thing that I thought of is using reverse SSH connections (either with ssh -R through a systemd service, or autoSSH) although that implies having one redirected port for each device. This is not really a problem and I doubt I'll have more than ~50K devices running at the same time.
However, I am looking for a more easy to manage infrastructure, and more scalable, just in case. I tried looking into other questions and I can't find an answer on this problem. I see that some people recommend using VPN tunnels, connecting each device to the central one. If someone just could explain how it works it would be great, I don't really understand how would that work, where do I setup each device ID/name, and how do I start a remote connection once it is all running.
Any other approach or solution is also welcome.
Note 1: One by one remote access is enough I think, but if all where available (so as to send commands to group of devices) will also be helpful (but don't stop answering if one at a time solution is in your mind).
Note 2: Systems are debian based. (Raspbian. it could also be Ubuntu if needed)