SSH to the Dongle over WAN?

Hey Folks - If I get a dongle with 4G modem, is it possible to ssh to the dongle via wan? I guess somehow the 4G modem must dynamically assign an IP address and DNS configuration. If I knew the WAN-assigned IP address, could I ssh to the RaspberryPi?? Has anyone done this?

Hi @andyl,

It may be possible to get the IP, but typically this is a dynamic up and is closed to ssh login by your network carrier. What we recommend is that you install a VPN or something like ZeroTier on your device. This will give you SSH access.

https://www.zerotier.com/

best
Peter

I’ve implemented a few different ways to SSH directly to my AutoPi dongle over WAN. Here’s the outline of my approaches:

Option 1: Using ngrok (free) service
Have ngrok automatically start TCP tunnel on RPi startup.
You may review the URL of the tunnel in your ngrok dashboard.
Alternatively, implement a bash script to query ngrok’s local web API and have it post to your email/slack.

Option 2: Using Reverse SSH Tunnel
This option is only suitable if you already own a VPS with static IP address.
I created a self-healing Reverse SSH service in RPi and have it always connect to my VPS server.
When I need to SSH to my RPi, I do that inside my VPS server. Note: that is how reverse SSH works, it’s a little mind-blown.
Some references:
https://blog.stigok.com/2018/04/22/self-healing-reverse-ssh-systemd-service.html
https://www.howtogeek.com/428413/what-is-reverse-ssh-tunneling-and-how-to-use-it/

Both of these approaches are ok even when the telco is giving you private IP address

@torinnguyen thanks - looks like a very sensible approach. How reliable has it being for you ?

both options work all the time for me.
My car is parked in the basement of my condo. When I need to access it (while not driving), I send an SMS to wake it up & start SSH in via my VPS server or via ngrok URL directly to my NodeRED.

Here’s a screenshot of my autopi event in Slack

There’s a much simpler way using ZeroTier too.