Last active
November 30, 2023 23:04
-
-
Save chaddupuis/db282205c979b21385338a0525cc2886 to your computer and use it in GitHub Desktop.
macOS Cisco AnyConnect CLI Connect Without Password (using macOS keychain)
This file contains 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/sh | |
VPNNUM=#you might not have a choice here, so possibly not needed | |
ADDRESS=vpn.com | |
USER=yourusername | |
PASS=$(security find-generic-password -a yourusername -l yourkeylistitem -w) | |
/usr/bin/expect -f - <<EOD | |
set timeout 20 | |
spawn /opt/cisco/anyconnect/bin/vpn connect $ADDR | |
expect "\r\nGroup:*" {send -- "$VPNNUM\r"} ##may not need | |
expect "\r\nUsername:*" {send -- "$USER\r"} | |
expect "\r\nPassword: " {send -- "$PASS\r"} | |
expect "Connected" | |
EOD | |
# /opt/cisco/anyconnect/bin/vpn disconnect to disconnect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment