Posted on Tue 02 February 2016

For some reason my autossh job is failing to set up the reverse tunnel so I can find and connect to my Pi when the Pi is roaming. Until I figure out why that is happening, I wrote this bash script which will upload the wifi interface's current IP ...

For some reason my autossh job is failing to set up the reverse tunnel so I can find and connect to my Pi when the Pi is roaming. Until I figure out why that is happening, I wrote this bash script which will upload the wifi interface's current IP address to a remote server.

1
2
3
4
#!/bin/bash

echo `ifconfig wlan0 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'` | \
    ssh [email protected] "cat > ~/myip.txt"

I already have ssh passwordless logins in set up because of autossh. If you don't have that set up, then you'll need to do that first or this won't work. I then add a cron job to run this script every minute.


comments powered by Disqus

Links