AppleScript to create a VPN

I am looking for an applescript to create a VPN in system preferences graphically (or if there is a better way, I am open to suggestions :smiley: )
This is all I have so far…


tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.network"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		delay 2
		tell window "Network"
			click button 5
			click pop up button 3
		end tell
	end tell
end tell

It won’t get the third (or second) popup button on the screen (interface)?? Past this I need to select the interface VPN, enter text in the name box, click ok, then enter text in the server address box and the account name box, then click authentication settings, and enter text in the password and shared secret box. Then click ok, and apply

Thanks in advance!
Robert

I used to set up a VPN this way, then point Screen Sharing.app at 127.0.0.1. The first line just sets my target IP address for the second line. See the man page for ssh. This opens up a terminal session where you have to enter the username and password for the other end. The first 55900 is the port to use out, the second is the port that will be open at the other end (with SSH enabled in Sharing).

 set target_IP to validIPAddressHere
tell application "Terminal" to do script "ssh -L 55900:127.0.0.1:5900 " & currIP

I didn’t want to use ssh because this would be for a client machine and this ssh would allow me to tunnel to the client if they had an external ip that I knew or they could tunnel to me and take over my computer :o . I need them to be able to connect to my external ip so that they show up in my vpn server client list and then I can provide full support almost as if they were on the LAN.
The script would add an L2TP VPN to the network interface, and then another script (that the client can activate when they need help) would automatically connect the VPN (Already in use…). I also use more than just the screen sharing service. L2TP VPN is a must.
Thank you for your reply! :slight_smile: