Skip to content

Instantly share code, notes, and snippets.

@catherio
Created August 29, 2016 20:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save catherio/72ab7fc51466323bd6647d9679dcb9b3 to your computer and use it in GitHub Desktop.
Save catherio/72ab7fc51466323bd6647d9679dcb9b3 to your computer and use it in GitHub Desktop.
Convert .ovpn config file for use with Ubuntu's network manager
#!/bin/bash
# This script will extract the certificate and key from an .ovpn file
# into their own files, which makes it possible to use them to configure
# the VPN using Ubuntu's network manager
# Usage example:
# >> ovpnconvert username.dev.ovpn
# You can keep following these instructions here:
# https://naveensnayak.wordpress.com/2013/03/04/ubuntu-openvpn-with-ovpn-file/
sed '1,/<ca>/d;/<\/ca>/,$d' $1 > $1.ca.crt
sed '1,/<cert>/d;/<\/cert>/,$d' $1 > $1.client.crt
sed '1,/<key>/d;/<\/key>/,$d' $1 > $1.client.key
sed '1,/<tls-auth>/d;/<\/tls-auth>/,$d' $1 > $1.ta.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment