There is no way to save password when logging into Cisco IPSec VPN on macOS.
The best solution to me is writing an AppleScript in Automator or run it from command line to automate the login.
AppleScript in Automator
Open Apple’s Automator,
Choose
New Document
Select
Service
The service created hasreceives selected
text
by default. It means you need to select text or having focus in a text editor to enable the service.Try to search for action
Run AppleScript
. Then, drag the action into the right-hand-side.Paste below code into the editor,
1 | on run {input, parameters} |
- Update
vpn_name
,username
andpasswd
in the script.
You can take reference from below screenshot for the vpn_name
, which is VPN (Cisco IPSec)
. The script uses scutil --nc status
to check the VPN connection status, and scutil --nc start
to start the VPN connection. Usually the VPN login dialog shows within 3 seconds. If your laptop is slow please update value in delay 3
. Try to run the script with the play button to see how it is automated.
Save the script with a name such as
VPN Login
.
In the System Preferences->Keyboard->Shortcuts, you can see the automation script. Assign a shortcut key. The script is assigned to text service by default during the service creation. You will need to select text or having focus in a text editor to enable the keyboard shortcut.Try to select text from an text editor such as Atom. With the proper shortcut key setup you should have the VPN login automated. It should works with Sierra or below but I haven’t tested it. Please let me know your result in older macOS.
AppleScript from command line
Open Apple’s Script Editor,
Choose
New Document
Paste below code into the editor. Please refers to AppleScript in Automator
1 | set vpn_name to "'your VPN name'" |
- Save the script. You can run the script with
osascript [programfile]
from Terminal.
Have fun!