-
-
Save antonengelhardt/c920a42a1fb8ce9e9f301b57da3b8c59 to your computer and use it in GitHub Desktop.
Connect to WWU VPN using openconnect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bin/bash | |
# This script is used to connect to the WWU VPN. It is meant to be used with a | |
# keyboard shortcut. Change the Constants before running the script. | |
USER=<put-your-wwu-id-here> | |
PASSWORD=<put-your-wlan-netzzugangspasswort-here> | |
OTP_CODE=$(oathtool --totp <put-your-base-16-keimwert-here-get-it-from-wwu-it-portal> | |
VPN_HOST=vpn.uni-muenster.de | |
# use openconnect to connect to the VPN | |
if pgrep openconnect > /dev/null | |
then | |
echo "Disconnecting from VPN..." | |
sudo killall openconnect | |
else | |
echo "Connecting to VPN..." | |
{ echo ${USER}; echo ${PASSWORD}; echo ${OTP_CODE}; } | sudo openconnect -b -q ${VPN_HOST} | |
fi |
Aliases in Terminal
Es ist ebenso möglich die Ausführung des Skriptes oder Teile davon in eigene Befehle zu verpacken - Stichwort "Alias"
Alle Befehle erfordern ggfs. das Computer-Passwort.
Der Befehl wwu-vpn-check
produziert keine Ausgabe, wenn der VPN nicht aktiv ist und gibt die ID des Prozesses wieder, wenn der VPN aktiv ist.
Für zsh
Datei ~/.zshrc
anpassen:
alias wwu-vpn-connect="sh ~/Documents/scripts/wwu-vpn.sh" // Je nachdem wo das Skript liegt
alias wwu-vpn-disconnect="sudo killall openconnect"
alias wwu-vpn-check="sudo pgrep openconnect"
Für fish
Datei in ~/.config/fish/config.fish
alias wwu-vpn-connect "sh ~/Documents/scripts/wwu-vpn.sh" // Je nachdem wo das Skript liegt
alias wwu-vpn-disconnect "sudo killall openconnect"
alias wwu-vpn-check "sudo pgrep openconnect"
The script is now being maintained here
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GitHub Repo
The script is now being maintained in a GitHub Repo as more contributors joined. Feel free to contribute aswell
Run
To run this script, use
sh wwu-vpn.sh
When you are prompted for a password, enter the password which you use to login to your computer.
Before running:
Install tools
Before you run this script, install:
With brew:
brew install oath-toolkit; brew install openconnect
Change constants:
At the top of the script, change the values accordingly:
USER=mmuster1 PASSWORD=verysecurepassword OTP_CODE=$(oathtool --totp 100000000000000000005224)
The Keimwert is displayed in the WWU-IT-Portal when you create your OTP profile. It is the "Keimwert im Base16-Format"
Disconnect
To disconnect, run the script again. It should disconnect you automatically.
To manually disconnect, run:
sudo killall openconnect
Feedback & Questions
Feedback and Questions are appreciated