Friday, May 3, 2013

Beranda » , » Create a VPN Shortcut in OS X

Create a VPN Shortcut in OS X

A virtual private network, or VPN, is a method of securely connecting to a network from a remote location, and is commonly used in work environments. While some institutions require the use of third-party VPN client software, others allow the use of Apple's built-in VPN clients.
In these cases, you can choose to enable the VPN menu in the OS X menu bar, and can then use it to quickly establish a VPN connection. However, if you are regularly connecting to your VPN, you may choose to also implement a hot-key shortcut to speed things up a bit more.

This workflow will connect a VPN service called 'MyVPN (PPTP)' when run (click for larger view).
(Credit: Screenshot by Topher Kessler/CNET)
To do this, you will need to use Apple's Automator program to link a small AppleScript routine to a hot key, which can be done by following this procedure:
  • Open the Automator utility and create a new "Service" workflow.
  • Set the workflow to receive "no input" in "any application" in the top-most menus.
  • Add the "Run AppleScript" action to the workflow, and replace its script contents with the following (adapted from MarkupBoy):
tell application "System Events"
     tell current location of network preferences
          set VPN to "SERVICE NAME"
          set VPNactive to connected of current configuration of service VPN
          if VPNactive then
               disconnect service VPN
          else
               connect service VPN
          end if
     end tell
end tell
  • Be sure to replace SERVICE NAME with the name of your VPN connection, which can be looked up in the Network system preferences (if the name is truncated, click the Advanced... button and view the full name at the top of the Advanced Settings panel).
  • Save the workflow with a name like "Connect to VPN"
When this is finished, go to the Keyboard system preferences and select the Keyboard Shortcuts tab, where you can locate the "Connect to VPN" service in the Services section, and assign a custom keyboard shortcut to it. You should now be able to toggle your VPN connection on and off from within any application by using this shortcut.

Note: If this tutorial worked for you (and it should work), please leave a comment below. Thanks.