A secure, automated OpenConnect VPN client for Linux with GNOME keyring-based credential management and TOML configuration. Automatically generates OTP tokens and manages VPN connections with enterprise-grade security.
- π Secure Credential Management: Uses GNOME keyring for OAuth tokens and PINs
- β‘ Automated OTP Generation: Generates time-based OTP tokens automatically
- π TOML Configuration: Clean, structured configuration in
~/.config/vpn/config.toml - π‘οΈ Enterprise Security: Supports F5 BigIP and other enterprise VPN protocols
- π Comprehensive Logging: Detailed logs via systemd journal (
journalctl -t AUTO-VPN) - οΏ½ VPN Monitoring: Automatic reconnection on network changes, suspend/resume, and idle detection
- οΏ½π§ͺ Fully Tested: Comprehensive test suite covering all functionality
- π Modern Python: Requires Python 3.13+ with full type annotations
- π§ Linux Native: Designed specifically for Linux with GNOME desktop
- Installation
- Quick Start
- Configuration
- Usage
- VPN Monitoring
- Development
- Security
- Troubleshooting
- License
- Python 3.13+ (required)
- Linux with systemd (for logging)
- GNOME Desktop Environment (for keyring integration)
- OpenConnect (for VPN connectivity)
Use the included Makefile for automatic dependency installation:
# Show available commands
make help
# Detect your OS and install dependencies
make install
# Install VPN monitoring system (requires install first)
make install-vpn-monitor
# Test installation in Docker containers
make test
# Test VPN monitor installation
make test-vpn-monitor
# Test specific distribution only
make test fedora
make test-vpn-monitor ubuntu# Install system dependencies
sudo dnf install python3.13 python3.13-pip openconnect libsecret-tools gnome-keyring hatch# Install system dependencies
sudo apt update
sudo apt install python3.13 python3.13-pip openconnect libsecret-tools gnome-keyring hatchpip install auto-openconnectgit clone https://github.com/vcwild/auto-openconnect.git
cd auto-openconnect
pip install -e .mkdir -p ~/.config/vpn
cat > ~/.config/vpn/config.toml << EOF
[vpn]
user = "your_username"
vpn = "https://your-vpn-server.com"
protocol = "f5"
EOFsetup-keyringThis will prompt you to securely store your OAuth token and PIN in the system keyring.
auto-openconnectOr use the convenient wrapper script:
vpn on # Connect
vpn off # Disconnect
vpn check # Check statusThe main configuration is stored in ~/.config/vpn/config.toml:
[vpn]
# VPN Connection Configuration
user = "your_username"
vpn = "https://your-vpn-server.com"
protocol = "f5"
# Note: Sensitive data (OAuth token and PIN) are stored securely in GNOME keyringYou can override the default config location:
# For bash/zsh
export AUTO_OPENCONNECT_CONFIG="~/.config/vpn/config.toml"
# For fish shell
set -gx AUTO_OPENCONNECT_CONFIG "~/.config/vpn/config.toml"Sensitive credentials are stored securely using GNOME Keyring, which integrates seamlessly with the GNOME desktop environment and provides encrypted storage for secrets.
# Connect to VPN
auto-openconnect
# Generate password only (for custom scripts)
get-vpn-password
# Setup or update keyring secrets
setup-keyring
# Check connection status
journalctl -t AUTO-VPN -fAuto-openconnect includes a comprehensive VPN monitoring system that provides automatic reconnection on various system events, ensuring your VPN connection stays active and reliable.
- π Network Change Detection: Automatically reconnects when switching between WiFi networks or ethernet connections
- π΄ Suspend/Resume Handling: Reconnects VPN after laptop sleep/wake cycles
- β° Idle Detection: Monitors user activity and reconnects when returning from idle (>5 minutes)
- π Connectivity Monitoring: Detects VPN failures and automatically reconnects
- π§ Smart Logic: Only attempts connection when internet connectivity is available
- π Comprehensive Logging: Tracks all VPN activities and decisions in
~/.local/share/vpn-monitor.log
Install the VPN monitoring system:
# Install VPN monitoring (requires base installation first)
make install-vpn-monitor
# Or run the installation script directly
./scripts/install-vpn-monitor.shThis installs:
- VPN Monitor Script:
~/.local/bin/vpn-monitor - Systemd Timer: Runs monitoring every 2 minutes automatically
- NetworkManager Dispatcher: Responds to network changes immediately
- Documentation: Complete setup and troubleshooting guides
The VPN monitor runs automatically once installed. You can also control it manually:
# Check monitoring status
systemctl --user status vpn-monitor.timer
# View live monitoring logs
tail -f ~/.local/share/vpn-monitor.log
# Run monitor manually (for testing)
~/.local/bin/vpn-monitor
# Stop/start monitoring
systemctl --user stop vpn-monitor.timer
systemctl --user start vpn-monitor.timer
# Disable monitoring
systemctl --user disable vpn-monitor.timerTest the monitoring system by triggering network events:
# Test network reconnection
sudo nmcli networking off && sleep 5 && sudo nmcli networking on
# Check logs to see monitoring response
tail -f ~/.local/share/vpn-monitor.logFor detailed installation instructions, troubleshooting, and advanced configuration:
- Installation Guide:
scripts/INSTALL-VPN-MONITOR.md - Files Reference:
scripts/VPN-MONITOR-FILES.md
Test the VPN monitor installation in Docker containers:
# Test VPN monitor on all distributions
make test-vpn-monitor
# Test on specific distribution
make test-vpn-monitor fedora
make test-vpn-monitor ubuntugit clone https://github.com/vcwild/auto-openconnect.git
cd auto-openconnect
# Install system dependencies
make install
# Install project
hatch run pip install -e .# Run tests
hatch run test
# Run integration tests
hatch run test-integration
# Lint code
hatch run lint
# Format code
hatch run format
# Type checking
hatch run type-check
# All checks (lint + format + type + test)
hatch run all-checksTest the installation process in isolated Docker containers:
# Test base installation on all supported distributions
make test
# Test VPN monitor installation on all distributions
make test-vpn-monitor
# Test specific distribution only
make test fedora
make test-vpn-monitor ubuntu
# Run all tests (base + VPN monitor)
make test-allThe Docker testing uses parameterized containers that test both base installation and VPN monitor installation with the same underlying images, ensuring consistency and faster feedback through layer caching.
auto-openconnect/
βββ src/auto_openconnect/
β βββ auth.py # Authentication logic
β βββ config.py # Configuration management
β βββ connect.py # Main connection logic
β βββ exec.py # Process execution
β βββ keyring_utils.py # Keyring management
β βββ lib.py # OTP generation
β βββ log.py # Logging setup
β βββ password_generator.py # Password-only entry point
βββ tests/ # Comprehensive test suite
βββ scripts/ # Installation and testing scripts
β βββ install-deps.sh # System dependency installer
β βββ install-vpn-monitor.sh # VPN monitor installer
β βββ test-install.sh # Docker-based installation tests
β βββ vpn # VPN control script
β βββ vpn-monitor # VPN monitoring script
β βββ INSTALL-VPN-MONITOR.md # VPN monitor installation guide
β βββ VPN-MONITOR-FILES.md # VPN monitor files reference
β βββ systemd/ # Systemd service files
β β βββ vpn-monitor.service # Systemd user service
β β βββ vpn-monitor.timer # Systemd user timer
β βββ networkmanager/ # NetworkManager integration
β βββ 99-vpn-monitor # NetworkManager dispatcher script
βββ docker/ # Docker containers for testing
β βββ Dockerfile.fedora # Fedora test environment (parameterized)
β βββ Dockerfile.ubuntu # Ubuntu test environment (parameterized)
βββ Makefile # Installation and testing interface
βββ pyproject.toml # Project configuration
βββ README.md # This file
- OAuth Tokens: Stored in GNOME keyring with service name
auto-openconnect - PINs: Encrypted using GNOME keyring
- Configuration: Non-sensitive data in TOML format
- Logs: Sensitive data is never logged
Verify your stored credentials:
# Check OAuth token (first 8 chars)
secret-tool lookup service auto-openconnect key oauth_token | head -c 8
# Check PIN (masked)
secret-tool lookup service auto-openconnect key pin | sed 's/./*/g'- Never commit credentials to version control
- Use GNOME keyring for all sensitive data
- Regularly rotate OAuth tokens and PINs
- Monitor logs for suspicious activity
- Keep dependencies updated for security patches
# Check config file exists
ls -la ~/.config/vpn/config.toml
# Check config format
cat ~/.config/vpn/config.toml# Verify keyring setup
setup-keyring
# Check keyring backend
python -c "import keyring; print(keyring.get_keyring())"
# Manual keyring test
secret-tool lookup service auto-openconnect key oauth_token# Check VPN logs
journalctl -t AUTO-VPN -f
# Check OpenConnect process
ps aux | grep openconnect
# Check network connectivity
ping your-vpn-server.comEnable verbose logging:
# Watch logs in real-time
journalctl -t AUTO-VPN -f
# Get recent logs
journalctl -t AUTO-VPN -n 50- Check logs: Use
journalctl -t AUTO-VPN -n 20for recent logs - Run tests: Use
hatch run testto verify functionality - Verify config: Ensure
~/.config/vpn/config.tomlis properly formatted - Check keyring: Use
setup-keyringto verify stored credentials
auto-openconnect is distributed under the terms of the MIT license.