Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. SERVICE_NAME='my-example-vpn'
  4. SERVICE_URL='my-example-vpn.com'
  5.  
  6. if [[ ${#USER} > 1 ]]
  7. then
  8. read -p "Log in as ${USER}? [y/n] " LIA
  9. else
  10. LIA = 'n'
  11. fi
  12.  
  13. if [[ $LIA == 'y' ]] || [[ $LIA == 'Y' ]]
  14. then
  15. UN=$USER
  16. else
  17. read -p "VPN Username: " UN
  18. fi
  19.  
  20. PW_KC=$(security find-generic-password -a $UN -s $SERVICE_NAME -w 2> /dev/null)
  21. PW=''
  22.  
  23. if [[ ${#PW_KC} > 1 ]]
  24. then
  25. read -p "Use password from keychain? [y/n] " UPWKC
  26. if [[ $UPWKC == 'y' ]] || [[ $UPWKC == 'Y' ]]
  27. then
  28. PW=$PW_KC
  29. fi
  30. fi
  31.  
  32. if [[ ${#PW} == 0 ]]
  33. then
  34. read -sp "VPN Password: " PW
  35.  
  36. echo
  37. read -p "Store password in keychain? [y/n] " UPWKC
  38. if [[ $UPWKC == 'y' ]] || [[ $UPWKC == 'Y' ]]
  39. then
  40. security add-generic-password -a $UN -s $SERVICE_NAME -w $PW
  41. fi
  42. fi
  43.  
  44. echo -e "\nConnecting after sudo.."
  45. sudo sstpc --log-stderr --log-level 1 --cert-warn --user $UN --password $PW $SERVICE_URL usepeerdns require-mschap-v2 noauth noipdefault defaultroute refuse-eap noccp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement