Skip to content

Instantly share code, notes, and snippets.

@jigangkim
Created January 26, 2022 06:17
Show Gist options
  • Save jigangkim/e24e32faabdc29e017828911b13aca06 to your computer and use it in GitHub Desktop.
Save jigangkim/e24e32faabdc29e017828911b13aca06 to your computer and use it in GitHub Desktop.
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