Skip to main content

Virtual Private Network connection in the cloudmesh suite

Project description

cloudmesh-vpn

This library is a wrapper around openconnect that provides added functionality. Additional features include secure password saving that uses the native-OS keyring, as well as vpn-slicing, which only sends traffic destined for school servers through the VPN and keeps other traffic out of the tunnel. Perhaps most conveniently, this library provides an easy way to install openconnect via a package manager (chocolatey for Windows, homebrew for macOS) without requiring any other dependencies besides Python. The package manager is installed for you on-the-fly which installs openconnect.

School Tested VPN-Slicing
UVA  uva
FIU  fiu
UFL  uf
FAMU
NYU
UCI
GMU
OleMiss
SC

Install

Windows

Open any terminal (git bash, cmd, powershell) as administrator.

Download Python from the Python website. Your Python version can be checked with the command python -V. Try doing the following.

python -V
# hopefully that works, if not, use python3 instead of python from now on.
# in git bash run as administrator:
python -m venv ~/ENV3
# or, in cmd run as administrator:
python -m venv "%USERPROFILE%\ENV3"
#
# if you are in git bash then:
source ~/ENV3/Scripts/activate
# if you are in cmd then:
"%USERPROFILE%\ENV3\Scripts\activate.bat"
# now you see (ENV3)
pip install cloudmesh-vpn

Usage

To connect to the UVA Anywhere VPN, run

# YOU MUST BE IN YOUR VIRTUAL ENVIRONMENT.
# see the previous commands on how to activate it first.
cms vpn connect

For other organizations, the --service flag can be used:

cms vpn connect --service=ufl
# possible services are uva fiu ufl

Note- currently the output will be piped to the terminal and will end in response to Ctrl + C consider executing the following:

nohup cms vpn connect --service=ufl >/dev/null 2>&1

To disconnect from current VPN, run

cms vpn disconnect

To see info regarding your connection, run

cms vpn info

Troubleshooting

Sometimes DNS lookup is broken entirely

To fix:

Get-DnsClientNrptRule | Remove-DnsClientNrptRule -Force
netsh interface ipv4 delete winsservers name="Ethernet" all
netsh interface ipv4 delete winsservers name="Wi-Fi" all
rasdial /disconnect
net start dnscache
net stop dnscache
ping google.com

Linux and macOS

Requirements

We use the command openconnect. To check if it is available please use

$ which openconnect

If it is not available, on macOS do:

brew install openconnect

you can install it on Ubuntu with

$ sudo apt install openssl
$ sudo apt install openconnect
$ sudo apt install network-manager-openconnect

and in case you use gnome also:

$ sudo apt install network-manager-gnome
$ sudo apt install network-manager-openconnect-gnome

Getting certificates

We have tested this tool only with University of Virginia, but it should be simple to adapt. Just follow the instructions to obtain the certificates from your provider.

At UVA you find the certificate and other documentation at

we place all certificates into ~/.ssh/uva

mkdir -p ~/.ssh/uva
# You will receive a file ending in .p12. In this example we will assume it is named mst3k.p12.
cd ~/.ssh/uva
# wget https://download.its.virginia.edu/local-auth/universal/usher.cer
wget --no-check-certificate https://download.its.virginia.edu/local-auth/universal/usher.cer

To get a certificate for your device, go to

Fill it out and get the key. You will receive a file ending in .p12. In this example we will assume it is named mst3k.p12 and place it into ~/.ssh/uva/user.p12

It is important for us to rename this key to user.p12 so we have a simpler way of identifying it and writing this documentation.

Now convert the keys and certificates with the following commands

cd ~/.ssh/uva
openssl pkcs12 -in user.p12 -nocerts -nodes -out user.key
openssl pkcs12 -in user.p12 -clcerts -nokeys -out user.crt
openssl x509 -inform DER -in usher.cer -out usher.crt

Now your UVA directory should have the following files in it.

ls ~/.ssh/uva/
user.crt  user.key  user.p12  usher.cer  usher.crt

Install and using the command

You can now use the cloudmesh cms vpn command.

$ pip install cloudmesh-vpn
$ cms help

To connect use

$ cms vpn connect 

To disconnect

$ cms vpn disconnect

Acknowledgments

This work was in part funded by the NSF CyberTraining: CIC: CyberTraining for Students and Technologies from Generation Z with the award numbers 1829704 and 2200409.

Manual Page

Command vpn
===========

::

  Usage:
        vpn connect [--service=SERVICE] [--timeout=TIMEOUT] [-v] [--choco]
        vpn disconnect [-v]
        vpn status [-v]
        vpn info

  This command manages the vpn connection

  Options:
      -v       debug [default: False]
      --choco  installs chocolatey [default: False]

  Description:
    vpn info
       prints out information about your current location as
       obtained via the vpn connection.

    vpn status
        prints out "True" if the vpn is connected
        and "False" if it is not.

    vpn disconnect
        disconnects from the VPN.

    vpn connect [--service=SERVICE]
        connects to the UVA Anywhere VPN.

        If the VPN is already connected a warning is shown.

        You can connect to other VPNs while specifying their names
        as given to you by the VPN provider with e service option.


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudmesh_vpn-5.0.16.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudmesh_vpn-5.0.16-py2.py3-none-any.whl (24.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cloudmesh_vpn-5.0.16.tar.gz.

File metadata

  • Download URL: cloudmesh_vpn-5.0.16.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for cloudmesh_vpn-5.0.16.tar.gz
Algorithm Hash digest
SHA256 d96dfffbc549bd4f66749a42e4e5fb5a433e1c825842a90b0efdc4026ea3fe80
MD5 72155330ec335d2bbd0e39ccb2d6befa
BLAKE2b-256 9876a94ec92b773a72a98a91188075235a2b67ee978206e43abbf90297fc3314

See more details on using hashes here.

File details

Details for the file cloudmesh_vpn-5.0.16-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cloudmesh_vpn-5.0.16-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 072297ca8ce5b2e66be798bc3433047d80491e2d2211c96338ea913d945ed1a1
MD5 d93ee7831c08ea425664b8a2671a1654
BLAKE2b-256 c0132b374a8f0a17f2b3b8e1cce4258da173265aaa9c5d3f56e3b37152d1aa4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page