I'm running OpenConnect on my MacOS (10.11 El Capitan) box to access my university VPN servers which run Cisco AnyConnect. The Cisco AnyConnect app has a clunky GUI which doesn't store the password and requires you to enter it each time -- and it likes kicking you off the system with regularity. With a random long-length password, entering it each time is obviously a pain in the neck.
So right now, I start up my VPN session using the alternative, OpenConnect, by piping it the password through a shell script:
#!/bin/sh
echo 'mypassword' | sudo openconnect --config ~/.openconnect myuniversity.edu
But obviously I'd prefer not to have my password stored in cleartext. My harddrive is encrypted and I do suppose that any BadGuy® who is able to read a file in my home folder is capable of much more malicious things, but still...
Is there any to store the password? Ideally, I'd like the password to be stored in my MacOS Keychain and for the keychain to pass it to openconnect, but I'm unsure whether that's doable from the CLI.
p.s. Obviously if I could convince my university to either not use Cisco or to use a more secure cryptographic method than a password, I would.