Sometimes you want to verify that a remote host is currently connected to a VPN, before performing an additional action. Here is a script to verify that host is VPN’ed
Verify that Host is VPN’ed
Maybe you use an non-logging VPN service, like EarthVPN, and you want to find out if your host is still on the VPN, prior to initiating a torrent download of a fully legal Linux ISO or other opensource software package.
I found it easiest to see if the VPN is still up, by checking that host’s public IP, from the perspective of an online resource.
REMOTE=$(ssh firstname.lastname@example.org “wget http://ipinfo.io/ip -qO -“)
- curl (on your workstation)
- wget (on the VPN host)
- ssh pubkey auth (to simplify)
Create this script on your workstation or desktop. If you want to avoid typing the SSH password every time you run this script, do an SSH PubKey on the remote VPN host.