These steps are for running Cisco AnyConnect in headless mode (no GUI and icon in the dock) and automatically providing VPN credentials using a response file.
Tested on
- macOS Monterey 12.2.1
- Cisco AnyConnect Secure Mobility Client 4.9.05042
-
Create a symbolic link to /opt/cisco/anyconnect/bin/vpn in /usr/local/bin/anyconnect
ln -s /opt/cisco/anyconnect/bin/vpn /usr/local/bin/anyconnect
-
Create a response file in ~/.config/anyconnect/response.txt containing your username and password.
mkdir -p ~/.config/anyconnect tee -a ~/.config/anyconnect/response.txt > /dev/null <<"EOF" <YOUR-USERNAME-HERE> <YOUR-PASSWORD-HERE> EOF
Note: The empty line after the password is important. See the sample-response.txt included with this gist.
Run anyconnect connect, passing your VPN server URL and path to response file.
anyconnect connect vpn.example.com -s < ~/.config/anyconnect/response.txtTip: You can add an alias to your shell configuration to make it even easier to connect, for example:
-
Add this to .zshrc (for zsh users) or .bash_profile (for bash users):
alias connect_vpn="anyconnect connect vpn.example.com -s < ~/.config/anyconnect/response.txt" -
Restart your terminal.
-
Now, to connect to your VPN, you can simply type
connect_vpn
anyconnect disconnectanyconnect state