-
-
Save gema-arta/d6f7fb44768dbab1884049beced745d2 to your computer and use it in GitHub Desktop.
Script to start sstp-client on a Mac, connecting to Microsoft VPN, with ability to use Apple's KeyChain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVICE_NAME='my-example-vpn' | |
SERVICE_URL='my-example-vpn.com' | |
if [[ ${#USER} > 1 ]] | |
then | |
read -p "Log in as ${USER}? [y/n] " LIA | |
else | |
LIA = 'n' | |
fi | |
if [[ $LIA == 'y' ]] || [[ $LIA == 'Y' ]] | |
then | |
UN=$USER | |
else | |
read -p "VPN Username: " UN | |
fi | |
PW_KC=$(security find-generic-password -a $UN -s $SERVICE_NAME -w 2> /dev/null) | |
PW='' | |
if [[ ${#PW_KC} > 1 ]] | |
then | |
read -p "Use password from keychain? [y/n] " UPWKC | |
if [[ $UPWKC == 'y' ]] || [[ $UPWKC == 'Y' ]] | |
then | |
PW=$PW_KC | |
fi | |
fi | |
if [[ ${#PW} == 0 ]] | |
then | |
read -sp "VPN Password: " PW | |
echo | |
read -p "Store password in keychain? [y/n] " UPWKC | |
if [[ $UPWKC == 'y' ]] || [[ $UPWKC == 'Y' ]] | |
then | |
security add-generic-password -a $UN -s $SERVICE_NAME -w $PW | |
fi | |
fi | |
echo -e "\nConnecting after sudo.." | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment