On Mac OS X <= 10.10, I could run the following command to open a VPN connection window:
function go-vpn {
/usr/bin/env osascript <<-EOF
tell application "System Events"
tell current location of network preferences
set VPN to service "LF VPN"
if exists VPN then connect VPN
repeat while (current configuration of VPN is not connected)
delay 1
end repeat
end tell
end tell
EOF
}
This would open the connection window (same as selecting the "LF VPN" network from the VPN dropdown). In El Capitan, however, I get the following error:
execution error: System Events got an error: Can’t get current configuration of service id "18E8C59B-C186-4669-9F8F-FA67D7AA6E53" of network preferences. (-1728)
How would one do the equivalent of this in El Capitan, and how can this be debugged?
Try to reinstall the app's profile, it should fix the issue; From System Preferences > Network> select Hotspot Shield VPN profile. Click on the minus "-" sign at the bottom to remove the profile. Click Apply to save changes.
Check your Firewall settings so that it doesn't interfere with your VPN traffic or blocks VPN data packets. Switch to a newer or lighter VPN protocol as described above. On rare occasions, a VPN may act up when you tap in WiFi, so try accessing the internet via cable.
When using the Default profile with Configuration: for the VPN and modifying its settings, the /Library/Preferences/com. apple. networkextension. plist file, the one starting in the root of the e.g. Macintosh HD, not your Home folder, will contain the VPN settings.
I'm using scutil
instead, and it works flawlessly on OS X 10.11
set vpn_name to "'VPN Connection Name'"
set user_name to "my_user_name"
set otp_token to "XYZXYZABCABC"
tell application "System Events"
set rc to do shell script "scutil --nc status " & vpn_name
if rc starts with "Connected" then
do shell script "scutil --nc stop " & vpn_name
else
set PWScript to "security find-generic-password -D \"802.1X Password\" -w -a " & user_name
set passwd to do shell script PWScript
-- installed through "brew install oath-toolkit"
set OTPScript to "/usr/local/bin/oathtool --totp --base32 " & otp_token
set otp to do shell script OTPScript
do shell script "scutil --nc start " & vpn_name & " --user " & user_name
delay 2
keystroke passwd
keystroke otp
keystroke return
end if
end tell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With