Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. set -euo pipefail
  4.  
  5. usage="$0: <up|down|state|stats> [connection name]"
  6. action="${1?$usage}"
  7. connection="${2:-GDS VPN Developer}"
  8.  
  9. oath_key=gds-vpn
  10. pass_key=gds/vpn
  11.  
  12. case "$action" in
  13. up)
  14. otp=$(ykman oath code "$oath_key" | awk '/[0-9]$/ { print $NF; }')
  15. : "${otp:?OTP not found}"
  16.  
  17. password=$(pass "$pass_key")
  18.  
  19. # Shut down the GUI app, which doesn't get along with the CLI tool
  20. pkill "Cisco AnyConnect Secure Mobility Client" || :
  21.  
  22. echo -e "${USER}\n${password}\n${otp}" | \
  23. /opt/cisco/anyconnect/bin/vpn -s connect "$connection" | \
  24. grep --line-buffered -Fv 'Second Password'
  25. ;;
  26. down)
  27. /opt/cisco/anyconnect/bin/vpn -s disconnect
  28. ;;
  29. state)
  30. /opt/cisco/anyconnect/bin/vpn state
  31. ;;
  32. stats)
  33. /opt/cisco/anyconnect/bin/vpn stats
  34. ;;
  35. *)
  36. echo "$usage" >&2
  37. exit 1
  38. ;;
  39. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement