Home » Scripts » Verify that Host is VPN’ed

Verify that Host is VPN’ed

Verify that Host is VPN'ed

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 johndoe@ “wget http://ipinfo.io/ip -qO -“)
curl ipinfo.io/$REMOTE


  • 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.



As an Amazon Associate I earn from qualifying purchases. Read our Privacy Policy for more info.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.