Giter Club home page Giter Club logo

juniper-network-connect-vpn-applescript's Introduction

Automated Juniper Network Connect VPN AppleScript

Screenshot

This is a script that will assist you in automating your VPN connection using Network Connect by Juniper Networks. It was designed for VPN access at Grand Valley State University, but contains nothing GVSU-specific. It should work for all versions of Network Connect on Mac OS X 10.6+, but it has been tested on GVSU's student VPN with Mac OS 10.6 Snow Leopard, Network Connect version 7.1.10 (21187).

Recommended Installation

There are a number of ways to use this AppleScript. This is what I recommend.

Create a bin directory for yourself if you don't already have it, and add it to your PATH:

mkdir ~/bin
echo 'export PATH=~/bin:"$PATH"' >> ~/.bashrc

Reload your shell (assuming bash) so these modifications take effect:

exec bash

Next, download the script:

curl https://raw.github.com/seanfisk/juniper-network-connect-vpn-applescript/master/juniper.applescript > ~/bin/juniper

Make it executable:

chmod +x ~/bin/juniper

You can now use the script like so:

juniper my.gateway.example.com myusername mypassword

The script will detect whether you are connected to the VPN. If not connected, it will start Network Connect and attempt to connect. If connected, it will sign out of the connection and quit Network Connect.

Shell Function

The previous instructions get it working, but don't really automate much. I wanted to be able to log in to the VPN by simply typing vpn at the terminal. I don't type passwords for websites or SSH, so I shouldn't have to type it for a VPN either. Add this shell function to your .bashrc to complete the configuration:

vpn () {
  juniper my.gateway.example.com myusername mypassword &
}

It is backgrounded so you don't have to wait for the delay and get your shell back immediately.

Those who are security-minded may not like embedding their password directly into a shell function. If that describes you, you can use read to get the password instead:

Bash

vpn () {
  # -s: silent, turn off echo
  # -p: prompt
  read -sp 'VPN Password: ' password
  juniper my.gateway.example.com myusername "$password" &
}

Zsh

vpn () {
  # -s: silent, turn off echo
  read -s 'password?VPN Password: '
  juniper my.gateway.example.com myusername "$password" &
}

GVSU

As mentioned, this was created for use with GVSU's VPN. If you are a GVSU user, please use the following sample command-lines:

Student

juniper vpn.student.gvsu.edu studentusername studentpassword

See more about connecting in the GVSU VPN guide for students.

Faculty

juniper vpn.gvsu.edu facultyusername facultypassword

See more about connecting in the GVSU VPN guide for faculty.

But I use Windows or GNU/Linux!

I believe that Network Connect is scriptable on these operating systems, i.e., it has a command-line interface. I cannot confirm that yet. For some reason, on Mac OS X, Juniper decided not to give us this interface. Boo. That is what this AppleScript is designed to solve.

Credits

This AppleScript drew from two other scripts created for this purpose:

I also used a script from Macworld to help determine the "addresses" of the UI fields and button:

That script is committed in the repository as dumpobjects.applescript.

juniper-network-connect-vpn-applescript's People

Contributors

seanfisk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.