Last active
September 19, 2025 11:12
-
-
Save michaeldorner/003037e3ed0af179e955423e7ce292ba to your computer and use it in GitHub Desktop.
OpenConnect GlobalProtect wrapper for vpn.ohmportal.de with macOS Keychain support
This file contains hidden or 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 | |
| PORTAL="vpn.ohmportal.de" | |
| # Get username from Keychain | |
| USER=$(security find-generic-password -s "$PORTAL" -g 2>&1 | \ | |
| awk -F\" '/"acct"<blob>="/ {print $(NF-1); exit}') | |
| # Get password from Keychain | |
| PASS=$(security find-generic-password -s "$PORTAL" -w 2>/dev/null) | |
| # Fallback if not found | |
| if [[ -z "$USER" || -z "$PASS" ]]; then | |
| read -p "VPN username: " USER | |
| read -s -p "VPN password: " PASS; echo | |
| security add-generic-password -a "$USER" -s "$PORTAL" -w "$PASS" -U >/dev/null | |
| echo "Stored into Keychain." | |
| fi | |
| # Run OpenConnect | |
| printf "%s" "$PASS" | sudo openconnect --protocol=gp "$PORTAL" -u "$USER" --passwd-on-stdin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment