From 7a66600eeec7f073e6511a465e457993af62a951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=84nis=20Jansons?= Date: Thu, 25 Feb 2021 13:36:44 +0200 Subject: [PATCH] Allow manual pass/token input --- run-vpn.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/run-vpn.sh b/run-vpn.sh index 9e0723c..eca7a9b 100755 --- a/run-vpn.sh +++ b/run-vpn.sh @@ -46,20 +46,32 @@ while true; do # If yubikey is not used, use the TOTP seed if [[ -z "$OC_YUBIKEY" ]]; then - TOTP=$(oathtool --totp=sha1 -b "$SEED") - PASSWORD="$PASSWORD\n$TOTP" + + if [[ -z "$SEED" ]]; then :; else + TOTP=$(oathtool --totp=sha1 -b "$SEED") + PASSWORD="$PASSWORD\n$TOTP" + fi else YUBIKEY_TOTP="--token-mode=yubioath --token-secret=$OC_YUBIKEY" fi - echo -e "$PASSWORD" | sudo openconnect \ - --csd-wrapper hostscan-bypass.sh \ - --passwd-on-stdin \ - --os=mac-intel \ - $YUBIKEY_TOTP \ - $SCRIPT_INCLUDE \ - -u $USERNAME \ - $SERVER + if [ -z "$SEED" ] && [ -z "$OC_YUBIKEY" ]; then + sudo openconnect \ + --csd-wrapper hostscan-bypass.sh \ + --os=mac-intel \ + $SCRIPT_INCLUDE \ + -u $USERNAME \ + $SERVER + + else + echo -e "$PASSWORD" | sudo openconnect \ + --csd-wrapper hostscan-bypass.sh \ + --os=mac-intel \ + $YUBIKEY_TOTP \ + $SCRIPT_INCLUDE \ + -u $USERNAME \ + $SERVER + fi echo "Openconnect closed. Waiting 3 seconds." sleep 3