Created
June 21, 2024 06:48
-
-
Save viniciusgava/23c33d779eea753dda57b8c020a8d69b to your computer and use it in GitHub Desktop.
Connecting to a Open VPN by fetching the username and password from 1password CLI as a bash alias
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
function __myvpnalias() { | |
sudo \ | |
# OP read command: https://developer.1password.com/docs/cli/reference/commands/read/ | |
VPN_USER=$(op read 'op://REFERENCE/TO/VPN/USER_NAME') \ | |
VPN_PASSWORD=$(op read 'op://REFERENCE/TO/VPN/PASSWORD') \ | |
VPN_CONFIG_FILE='/PATH/TO/OPENVPN/CONFIG/FILE' \ | |
bash -c 'openvpn --script-security 2 --config $VPN_CONFIG_FILE --auth-user-pass <(echo -e "$VPN_USER\n$VPN_PASSWORD")' | |
} | |
alias myvpnalias="__myvpnalias" | |
# Reference threads | |
# - https://stackoverflow.com/questions/38869427/openvpn-on-linux-passing-username-and-password-in-command-line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment