Created
January 26, 2022 06:17
-
-
Save jigangkim/e24e32faabdc29e017828911b13aca06 to your computer and use it in GitHub Desktop.
This file contains 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
usage="usage: bash vpn.sh -c <config>" | |
quick_die() { | |
format="$1"; shift | |
>&2 printf "${format}\n" "$@" | |
exit 1 | |
} | |
main() { | |
while getopts "hc:" opt; do | |
case "${opt}" in | |
h) quick_die "${usage}" ;; | |
c) config="${OPTARG}" ;; | |
esac | |
done | |
shift $(( OPTIND - 1 )) | |
if [[ -z "${config}" ]]; then | |
quick_die "config file required" | |
exit 1 | |
fi | |
secret="U2FsdGVkX19hNdCDdGFHXlCAm7WUvzPXTsMSdyUvqmq38LwwOoMbQvOZlyBh4gYl" | |
echo -n "password: " | |
read -s password | |
echo | |
user=`echo $secret | openssl aes-256-cbc -pbkdf2 -d -a -pass pass:$password` | |
auth="${user}\n${password}" | |
openvpn --config ${config} --auth-user-pass <(echo -e "${auth}") --hand-window 10 | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment