Skip to content

Instantly share code, notes, and snippets.

@xfun68
Created November 25, 2019 08:12
Show Gist options
  • Select an option

  • Save xfun68/fcfa66f9cf9dd3854c9790419f33c0b1 to your computer and use it in GitHub Desktop.

Select an option

Save xfun68/fcfa66f9cf9dd3854c9790419f33c0b1 to your computer and use it in GitHub Desktop.
Bash script to connect TW vpn
#!/bin/bash
function get_password {
echo `security find-generic-password -a $1 -s twvpn -w`
}
killall 'Cisco AnyConnect Secure Mobility Client' 2>/dev/null
/opt/cisco/anyconnect/bin/vpn disconnect >/dev/null
username=`get_password username`
password=`get_password password`
second_authentication_method=`get_password second_authentication_method`
secret_key=`get_password secret_key`
code=`oathtool --totp -b $secret_key`
/opt/cisco/anyconnect/bin/vpn -s connect $1.vpn.thoughtworks.com << EOF | sed 's/Password: .*/Password: ********/g'
$username
$password
$second_authentication_method
$code
EOF
open -g '/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment