Skip to content

Instantly share code, notes, and snippets.

@notpike
Last active January 27, 2021 18:29
Show Gist options
  • Select an option

  • Save notpike/728700e46d3ad5db38081f6633d888ca to your computer and use it in GitHub Desktop.

Select an option

Save notpike/728700e46d3ad5db38081f6633d888ca to your computer and use it in GitHub Desktop.
Import OpenVPN config files into Network Manager from current directory
#!/bin/bash
#Update UNAME and PASS and run from the directory where the .ovpn files reside
UNAME=""
PASS=''
echo "== START =="
for file in *; do
if [ -f "$file" ]; then
if [ ${file: -5} == ".ovpn" ]; then
echo "Importing" ${file::-5}
nmcli connection import type openvpn file "$file"
nmcli con modify "${file::-5}" vpn.user-name $UNAME
nmcli con modify "${file::-5}" vpn.secrets password=$PASS
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment