From 14a892e627a375334a02381351f139d94ad7ecf3 Mon Sep 17 00:00:00 2001 From: ダカマ Date: Mon, 2 Jun 2025 13:08:46 +0200 Subject: First dump --- scriptlets/old_veepeen_toggler.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scriptlets/old_veepeen_toggler.sh (limited to 'scriptlets/old_veepeen_toggler.sh') diff --git a/scriptlets/old_veepeen_toggler.sh b/scriptlets/old_veepeen_toggler.sh new file mode 100755 index 0000000..ad48082 --- /dev/null +++ b/scriptlets/old_veepeen_toggler.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +passentry="shigoto/vpn" +CONN_NAME="cscotun0" + +if [ -n "$(ip address show | grep -iE "^[0-9]+: $CONN_NAME")" ]; then + echo "ALREADY CONNECTED. DISCONNECTING..." + /opt/cisco/anyconnect/bin/vpn disconnect +else + CONN_HOST="$( pass $passentry | grep "url: "| sed -r "s|url: ||g" )" + CONN_CREDS_USERNAME="$( pass $passentry | grep "username: "| sed -r "s|username: ||g" )" + CONN_CREDS_PASSWORD="$( pass $passentry | head -n1 )" + echo "CONNECTING... DON'T FORGET YOUR PHONE VERIFICATION" + printf '%s\n%s' "$CONN_CREDS_USERNAME" "$CONN_CREDS_PASSWORD" | /opt/cisco/anyconnect/bin/vpn -s connect "$CONN_HOST" +fi + +: ' +Note the single quotes instead of double quotes - this is because double quotes tell Bash to interpret certain characters within strings, such as exclamation marks, as Bash history commands. Double quotes will make this command fail with an "event not found" error if the password contains an exclamation mark. Single-quoted strings pass exclamation marks along without interpreting them. + +In case your client does not connect due to certificate validation error Certificate is from an untrusted source, +and you still want to connect then pass a y parameter in the above method so that the command to connect becomes: +printf "y\nUSERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST. +Note that do this only in the case that you absolutely trust your connection; +otherwise there might be a middleman sitting in and snooping onto you. +' -- cgit v1.2.3