How to auto save a Cisco VPN connection password on Mac OS X?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping
--
Chapters
00:00 How To Auto Save A Cisco Vpn Connection Password On Mac Os X?
00:57 Answer 1 Score 5
02:13 Answer 2 Score 3
02:25 Answer 3 Score 3
02:47 Accepted Answer Score 2
02:55 Answer 5 Score 0
03:55 Thank you
--
Full question
https://superuser.com/questions/342702/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#macos #vpn #ipsec
#avk47
ANSWER 1
Score 5
I finally found a working solution. I'm using Anyconnect VPN secure mobility 4.8
We can use this to connect to Anyconnect with terminal
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.
Note the single quotes ' instead of double quotes " - this is because double quotes tell Bash to interpret certain characters within strings, such as exclamation marks, as Bash history commands. Double quotes will make this command fail with an "event not found" error if the password contains an exclamation mark. Single-quoted strings pass exclamation marks along without interpreting them.
To disconnect:
/opt/cisco/anyconnect/bin/vpn disconnect
I've made an alias to bash_profile to those commands
ANSWER 2
Score 3
There is a workaround with AppleScript that works for me.
ANSWER 3
Score 3
I got another script on github.
Instead of simulating click and input, this script access the process and simply triggers the actions.
While the first time the script runs, OSX may ask for accessibility.
ACCEPTED ANSWER
Score 2
In the bad old days of using Cisco's client, it was easy to edit the .pcf file to work around the remote server policy. Using the alternative client Shimo has worked for me as of a couple of years ago (it's now closed-source, but you can get the old version from Google Code). Here's another workaround I haven't tried that uses the Keychain.
ANSWER 5
Score 0
A better way to use Cisco Anyconnect could be by using it via command line.
Create a text file called anyconnect.txt
and add the following
connect vpn.website.com
0
username
password
y
exit
Here, replace the host, username and password. Also the 0
in 2nd line is for the GROUP. If you have more than 1 group, use the appropriate index.
Then the only command you need to start your VPN is:
/opt/cisco/anyconnect/bin/vpn -s < anyconnect.txt
Use the following command to disconnect:
/opt/cisco/anyconnect/bin/vpn disconnect
Make it more quick by defining these commands in your bash_profile like so:
# Cisco Anyconnect
alias cisco='/opt/cisco/anyconnect/bin/vpn -s < anyconnect.txt'
alias nocisco='/opt/cisco/anyconnect/bin/vpn disconnect'
Now, command cisco
will connect your VPN, and nocisco
will disconnect it!