Skip to content

Instantly share code, notes, and snippets.

@irfn
Last active October 2, 2018 14:17
Show Gist options
  • Save irfn/eea4616a29474f7590481326af3c00c4 to your computer and use it in GitHub Desktop.
Save irfn/eea4616a29474f7590481326af3c00c4 to your computer and use it in GitHub Desktop.
Launch Tunnelblick profile with a token generated by a yubikey google authenticator profile
#!/usr/bin/env bash
TOKEN=$(yubioath show $1 | sed "/$1/ s/[a-z ]*//g")
read -r -d '' SCRIPT_TEMPLATE <<-'END'
tell application "Tunnelblick"NL
connect "$PROFILE"NL
delay 1NL
tell application "System Events"NL
keystroke $TOKENNL
delay 1NL
key code 36NL
end tellNL
get state of first configuration where name = "$PROFILE"NL
repeat until result = "CONNECTED"NL
delay 1NL
get state of first configuration where name = "$PROFILE"NL
end repeatNL
end tell
END
echo $SCRIPT_TEMPLATE | sed -e "s/\$TOKEN/$TOKEN/g" -e "s/\$PROFILE/$2/g" | perl -pe "s/NL/\n/g" | osascript
@irfn
Copy link
Author

irfn commented Oct 25, 2016

Above script can be used to Launch a vpn profile with a Authenticator token on OSX
Needs the following
Yubikey authenticator application: brew cask install yubico-authenticator
Add a google authenticator profile in the Yubikey UI.

Launch via ./yubikey-tunnelblick.sh name-of-yubiney-profile name-of-tunnelblick-profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment