This gist is for Linux. For windows is the same thing.
create a file .login_info
as below:
connect your.server.url
usernanme
password
(blank line)
create a script as below
/opt/cisco/anyconnect/bin/vpn -s < .login_info
The input (content of .login_info
) may vary according to your settings. Try VPN shell to determine your inputs.
Run
/opt/cisco/anyconnect/bin/vpn -s
Now you are in command shell:
VPN>
Connect your server:
VPN> connect your.vpn.server
Input what asked, for me it's below:
Username: [xxxxx] xxxxx
Password: xxxxxx
Exit from VPN shell:
VPN> exit (or return)
Remember what you typed, and save them into the .login_info
file.
With this approach, the icon will not show in the taskbar, you need run command line vpn disconnect
to disconnect.
If you want to show the icon in the taskbar, add below line in the script:
/opt/cisco/anyconnect/bin/vpnui &
For those whose organizations are using MFA, you may need to add a few lines to the input file you are redirecting into vpncli. In my case, triggering the verification and accepting the agreement required adding PUSH and Yes (maybe Y would be sufficient) under the password line. Next I want to work on automating this at login, and of course if you have password rotation you will need to update your password in the configuration file after performing the rotation.