Skip to content

Instantly share code, notes, and snippets.

@diogosimao
Forked from bsless/vpn-setup.sh
Created November 17, 2022 19:25
Show Gist options
  • Save diogosimao/10df4e750c982b390d5696c08ccc63a0 to your computer and use it in GitHub Desktop.
Save diogosimao/10df4e750c982b390d5696c08ccc63a0 to your computer and use it in GitHub Desktop.
Set up a bunch of OpenVPN connections using nmcli with username and password
#!/usr/bin/env bash
USERNAME="$1"
PASS="$2"
for f in *.ovpn
do
name=`basename -s .ovpn $f`;
nmcli connection import type openvpn file $f
nmcli connection modify "${name}" +vpn.data connection-type=password-tls
nmcli connection modify "${name}" +vpn.data username="${USERNAME}"
nmcli connection modify "${name}" +vpn.secrets password="${PASS}"
done
@diogosimao
Copy link
Author

nmcli connection import type openvpn file "$FILENAME"

@diogosimao
Copy link
Author

https://askubuntu.com/a/913122

nmcli connection modify enp3s0 ipv4.never-default true
  • change enp3s0 with your own connection name.
  • use false or true to toggle between this config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment