I do that with Termux on my Android phone. I set up dynamic DNS and wireguard on my router so I can reach my LAN from anywhere. I just enable wireguard and ssh in.

Not sure if there's a Termux equivalent for iPhone.