User:Jtagcat/Automatically retrieve phone's IP to SSH in to with syncthing

From postmarketOS

Content moved by ollieparanoid from SSH to user's page since this is more of a personal setup description than something that can be used generically. Note that avahi may be used for similar purpose.

Automatically retrieve phone's IP to SSH in to

WARN: Not battle-tested, worst case it doesn't magically work. ifdata returns only the first address (usually the most local, ipv4 first).

On the phone:

$ sudo apk add syncthing moreutils # Get syncthing, ifdata (for lazy asses, lightweight asses might want to use something else)
$ sudo rc-update add syncthing # Start on startup
$ sudo rc-service syncthing start # ..or now
Setup syncthing, if using GUI, I'd recommend changing listen to 0.0.0.0:8384, but use https and set a pass!
$ sudo -u syncthing crontab -e
* * * * * echo $(ifdata -pa wlan0) > /var/lib/syncthing/wm/wlan0-ip.pinenode # wlan0 being the interface, wm is a synced directory, every minute might be too often.
:wq
$ sudo rc-update add crond
$ sudo rc-service crond start

On the ssh-er

Let's humbly assume we have syncthing set up on this machine.
Add to .whatever_aliases, .whateverrc .profile, or whatever:
$ alias pine="mosh $(cat ~/c/wm/wlan0-ip.pinenode)" # There's nothing really to explain.
I use byobu, but I definitely recommend it, tmux, screen, or something else!
mosh is just self-reconnecting shell (won't work if the target changes it's address).