As title says, trying to connect vpn via bash. The following script seemed closest to the answer I\'m looking for:
#!/bin/bash
/opt/cisco/anyconnect/bin/vpn
Although expect can be cleaner, it is not strictly necessary. Assuming /opt/cisco/anyconnect/bin/vpnagentd is running as it automatically should be:
To connect:
printf "USERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST
Replace USERNAME, PASSWORD, and HOST. The \ny at the end is to accept the login banner - this is specific to my host, and so you may not need it.
I understand that there are obvious security concerns with this method; it's for illustration purposes only.
To get state:
/opt/cisco/anyconnect/bin/vpn state
To disconnect:
/opt/cisco/anyconnect/bin/vpn disconnect
This was tested with AnyConnect v3.1.05160.