I ran into the same difficulty try to use Cisco AnyConnect from Mac OS X Terminal. To get the Cisco vpn command to take its input from standard input, you have to specify the -s option, which puts the Cisco vpn command into interactive mode. Then you can provide the responses that you give in interactive mode.
The responses that you need to give depend upon how the VPN server administrator has configured the server. For me, the vpn interactive prompts are
Group:
Username:
Password:
Blah, blah, blah, ...
accept? :
So the command that I run is
$ /opt/cisco/anyconnect/bin/vpn -s connect vpn.example.com <<"EOF"
0
username
password
y
exit
EOF
(The quotes around EOF are to prevent command/parameter expansion/substitution in the following input.)
The exit at the end is to exit the Cisco vpn interactive mode.
5In case your client does not connect due to certificate validation error
Certificate is from an untrusted source
, and you still want to connect then pass ay
parameter in the above method so that the command to connect becomes:printf "y\nUSERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST
. Note that do this only in the case that you absolutely trust your connection; otherwise there might be a middleman sitting in and snooping onto you. – shivams – 2015-04-22T11:38:30.0471Works beautifully (though my version needs a
GROUPNAME\nUSERNAME\nPASSWORDy
. If you want to keep your password separate from the command (which may be a shell script or a dotfile key binding), you can do this:cat ~/.anyconnect_credentials | /opt/cisco/anyconnect/bin/vpn -s connect HOST
– Sridhar Sarnobat – 2019-11-04T18:08:15.710@SridharSarnobat Using a separate file for the credentials works, but it prints out your password in the log like:
>> notice: Please respond to banner. MYPASSWORD
– Willian Vieira – 2019-11-19T20:05:03.430