Command line manager for multiple openVPN connections

Version 0.3 (20160314)

A fairly simple script, written in "Real Perl" (meaning I actually put in the --man and --help stuff) which controls OpenVPN connections. It was designed to open and keep multiple OpenVPN connections on a multi-user system (a terminal server, in this case).

Individual users call the script (vpn) with the name of the connection to make (defined as directories under /etc/openvpn). The script first checks whether the vpn connection is already open. If it is not, it is opened for all users, with log and pid files created.

Users do not have to manually shut down the connections (though they can with the -k flag); the connection is automatically timed out after a number of seconds defined in the script or via the -t parameter on initial call.

vpn must be run as root to create or kill a session. If called with no parameters, it displays all available connections (all directories in /etc/openvpn), with an indicator if the session is currently active.

NOTE: if the log and/or pid directories are not created, a call to vpn as non-root user results in an error, since the directories must be created by root. Simply running 'sudo vpn' or 'vpn' as the root user will create the log and pid directories.

To Install:

1. Copy the script vpn to some directory in the path, ie /usr/local/bin and chmod to 755

2. Create /etc/openvpn if it does not exist

3. Create a separate directory under /etc/openvpn for each connection, and include the .p12 and .ovpn file. You must modify the .ovpn file to use the fully qualified path to the .p12 file unless the --chdir option is given.

NOTE: the directory name and the .ovpn file name are assumed to be the same. For example, if we have two possible connections, one to "office" and one to "client1", the script would look for:



The PID and Log files would be named office and client1 respectively.

Download Here or use wget