Skip to content

Instantly share code, notes, and snippets.

@sugarjig
Last active December 7, 2016 15:18
Show Gist options
  • Save sugarjig/39b24745f728c44f8ad1192fed692365 to your computer and use it in GitHub Desktop.
Save sugarjig/39b24745f728c44f8ad1192fed692365 to your computer and use it in GitHub Desktop.
A couple of simple scripts to start and stop an OpenConnect session with a password in macOS Keychain
# This will create a file "pid" in the current directory that will be used in the stop script
background
pid-file=pid
user=$USER
passwd-on-stdin
#!/bin/bash
# Hard-code these values if you don't need to pass them in
# SERVER corresponds to the "Name" field in Keychain
# HOST is the URL used to connect to the VPN
SERVER=$1
HOST=$2
CONFIG=config
security find-internet-password -s $SERVER -w | openconnect --config=$CONFIG $HOST
#!/bin/bash
kill -s INT $(cat pid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment