Skip to content

Instantly share code, notes, and snippets.

@sloanlance
Last active April 13, 2020 20:08
Show Gist options
  • Save sloanlance/0bd8e7a2be8e1f1377971d41e07bcc8f to your computer and use it in GitHub Desktop.
Save sloanlance/0bd8e7a2be8e1f1377971d41e07bcc8f to your computer and use it in GitHub Desktop.
Mac OS X 10.11-ish shell script to toggle VPN connection
#!/bin/sh --
##
## Requires your VPN service to be already configured
## and your password saved in your keychain.
##
## Alter the VPN variable below to contain the name
## of your configured VPN service before running.
##
VPN='YOUR_VPN_NAME'
scutil --nc status "$VPN" | grep -q 'Connected'
if [ $? -eq 0 ]; then
scutil --nc stop "$VPN"
else
scutil --nc start "$VPN"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment