Created
December 20, 2022 10:37
-
-
Save zloyded/b922c2ff5d7cc50ea6792a0752e2e9f0 to your computer and use it in GitHub Desktop.
openconnect
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
vpnpass() { | |
printf "$R_PIN`oathtool -b --totp $R_TOKEN`" | pbcopy | |
} | |
vpnsetup() { | |
sudo sh -c 'echo "${SUDO_USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/openconnect' | |
} | |
vpnstart() { | |
vpnpass | |
pbpaste | sudo openconnect \ | |
--protocol anyconnect \ | |
--background \ | |
--pid-file="$HOME/.openconnect.pid" \ | |
--user=$WORKUNAME \ | |
$VPNADDR \ | |
--passwd-on-stdin | |
} | |
vpnstop() { | |
if [[ -f "$HOME/.openconnect.pid" ]]; then | |
sudo kill -2 $(cat "$HOME/.openconnect.pid") && rm -f "$HOME/.openconnect.pid" | |
else | |
echo "openconnect pid file does not exist, probably not running" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment