Created
November 25, 2019 08:12
-
-
Save xfun68/fcfa66f9cf9dd3854c9790419f33c0b1 to your computer and use it in GitHub Desktop.
Bash script to connect TW vpn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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