VPN Up - Shell Script for OpenConnect for Mac OS | Command-Line Client for Cisco AnyConnect
A shell script for OpenConnect which allows:
- to define multiple VPN connections, using different protocols
- to run openconnect without entering the username and password
- to run in the background / quietly
- to authenticate with a certificate
- to authenticate using Two-Factor Authentication (2FA) from Duo
- to check the status of the vpn connection
- 🆒 added support for Two-Factor Authentication (2FA) from Duo
- added support for using different protocols
- added options (start, stop, status, restart, status)
- can check status of the vpn connection
BACKGROUND=TRUE
# TRUE Runs in background after startup
# FALSE Runs in foreground after startup
QUIET=TRUE
# TRUE Less output
# FALSE Detailed output
# VPN PROFILE 1
export VPN1_NAME="My Company VPN"
export VPN1_PROTOCOL=anyconnect
# anyconnect Compatible with Cisco AnyConnect SSL VPN, as well as ocserv (default)
# nc Compatible with Juniper Network Connect
# gp Compatible with Palo Alto Networks (PAN) GlobalProtect SSL VPN
# pulse Compatible with Pulse Connect Secure SSL VPN
export VPN1_HOST=vpn.mycompany.com
export VPN1_AUTHGROUP=developers
export VPN1_USER=sorin.ipate
export VPN1_PASSWD="MyPassword"
export VPN1_DUO2FAMETHOD="push" # Duo 2FA Method
# passcode Log in using a passcode, either generated with Duo Mobile, sent via SMS, generated by your hardware token, or provided by an administrator. E.g. to use the passcode “123456," type 123456
# push Push a login request to your registered phone (if you have Duo Mobile installed and activated on your iOS, or Windows phone device). Just review the request and select Approve to log in.
# phone Authenticate via callback to your registered phone.
# sms Sends an SMS message with a new batch of passcodes to your registered device. Your initial login attempt will fail. Login again with one of the new passcodes.
export VPN1_SERVER_CERTIFICATE="SHA1-OtherCharachters" # SHA1
- Please make sure you have
openconnect
installed before moving on. Follow the instructions here. - Download the latest release.
- Copy the
vpn-up.command
file to thebin
folder. - Update the
vpn-up.command
file with the appropiate VPN connection information as shown above. - Make an alias
alias vpn-up='~/bin/vpn-up.command'
inbash
orzsh
shell. Follow the instructions here. - Run
vpn-up
to start and voilà.