- Open Keychain Access
- Navigate to "Login" in the left menu
- Cmd+N (New Password item)
- Fill in these details:
- Keychain Item Name: anyconnect
- Account name: Your username (firstname.lastname)
- Password
-
Create new command file (you will use this to open AnyConnect in the future)
touch /Applications/AnyConnect.command
-
Add this to the file (remember to change
EXAMPLE.COM
to your VPN domain)#! /bin/zsh /opt/cisco/anyconnect/bin/vpn connect EXAMPLE.COM -s << EOM $(security find-generic-password -s anyconnect | grep acct | awk -F\" '/acct"<blob>/ {print $4}') $(security find-generic-password -ws anyconnect) EOM osascript -e 'tell application "Terminal" to close (every window whose name contains "AnyConnect.command")'
-
Add execute permissions
chmod u+x /Applications/AnyConnect.command
-
Now verify by opening AnyConnect.command
open /Applications/AnyConnect.command
-
If everything goes right a new terminal will open up that will start AnyConnect in the background
... >> state: Connecting >> notice: Establishing >> notice: Establishing >> state: Connected Saving session...complete [Process completed]
-
To close AnyConnect you need to open the
Cisco AnyConnect Secure Mobility Client.app
to activate it's GUI and from there close the connect. Another way is to setup another command following the instruction below.
- Create another command file (you will use this to close AnyConnect)
touch /Applications/AnyConnect\ Disconnect.command
- Add this to the file
#! /bin/zsh /opt/cisco/anyconnect/bin/vpn disconnect osascript -e 'tell application "Terminal" to close (every window whose name contains "AnyConnect Disconnect.command")'
- Add execute permissions
chmod u+x /Applications/AnyConnect\ Disconnect.command
- Now verify by opening AnyConnect Disconnect.command
open /Applications/AnyConnect\ Disconnect.command
- This will open a new terminal and output something like this:
... >> state: Disconnecting >> notice: Disconnect in >> state: Disconnecting >> state: Disconnected Saving session...completed [Process completed]