Skip to content

Instantly share code, notes, and snippets.

@nxvhm
Forked from dleonard00/explode-opvn.sh
Created September 18, 2023 19:05
Show Gist options
  • Save nxvhm/098c9b01fe0af5357b36c04659edc3e6 to your computer and use it in GitHub Desktop.
Save nxvhm/098c9b01fe0af5357b36c04659edc3e6 to your computer and use it in GitHub Desktop.

Revisions

  1. @dleonard00 dleonard00 created this gist Jan 15, 2017.
    16 changes: 16 additions & 0 deletions explode-opvn.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/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