Skip to content

Instantly share code, notes, and snippets.

@BlkPingu
Created January 20, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlkPingu/79977b589a9da5936cb46d653f3227dd to your computer and use it in GitHub Desktop.
Save BlkPingu/79977b589a9da5936cb46d653f3227dd to your computer and use it in GitHub Desktop.
HTW Berlin Cisco any connect script

How to

  1. Install anyconnect command line tools
  2. Save vpn_htw.sh somewhere, like ~/.scripts
  3. put a new Alias in your .bashrc or .zshrc alias htw="sudo bash ~/.scripts/vpn_htw.sh"
  4. Fill out your credentials in the vpn_htw.sh where commented
  5. Source your rc file like source .bashrc
  6. launch with htw -c
#!/bin/bash/expect -f
arg1=$1
#group options:
# 0) HTW-SSL-Split
# 1) HTW-SSL-VPN-Full
# 2) HTW-SSL-VPN-Split
export GROUP="HTW-SSL-VPN-Full"
#known hosts:
# - SSL-VPNCL-HTW
export HOSTS=("SSL-VPNCL-HTW" "vpncl.htw-berlin.de")
export USER=s0XXXXXX@htw-berlin.de # < HIER AUSFUELLEN
export PW=XXXXXXXXX # < HIER AUSFUELLEN
server_array=("s0XXXXXX@dt9.f4.htw-berlin.de" "s0XXXXXX@hadoop05.f4.htw-berlin.de") # < HIER AUSFUELLEN
command_array=("[c] - connect to htw-vpn" "[dc] - disconnect from htw-vpn")
function connect_cisco {
printf "$GROUP\n$USER\n$PW" | /opt/cisco/anyconnect/bin/vpn -s connect $HOST
}
function plist() {
name=$1[@]
b=$2
a=("${!name}")
for i in "${a[@]}"
do
echo "$i"
done
}
if [ "$arg1" == "-c" ];
then connect_cisco
elif [ "$arg1" == "-dc" ];
then sudo pkill connect_cisco
ps -A | grep connect_cisco
else
printf "give args pls:\n"
plist command_array
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment