Created
April 29, 2023 06:44
-
-
Save dptole/4197a9f0e1f1249058955d8cd23c0a6f to your computer and use it in GitHub Desktop.
Import OpenVPN files en mass using nmcli (Network Manager CLI)
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
#!/usr/bin/bash | |
# You must be in the folder containing all *.ovpn files | |
username="USERNAME FOR ALL CONNECTIONS" | |
password="PASSWORD FOR ALL CONNECTIONS" | |
for path in `ls *.ovpn` | |
do | |
connectionName=$(basename $path ".ovpn") | |
nmcli --terse connection delete id "$connectionName" | |
nmcli --terse connection import type openvpn file "$path" | |
nmcli connection modify "$connectionName" vpn.persistent true | |
nmcli connection modify "$connectionName" vpn.user-name "$username" | |
nmcli connection modify "$connectionName" +vpn.data "password-flags = 0, username = $username" | |
nmcli connection modify "$connectionName" +vpn.secrets "password=$password" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment