Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
extract the certificate and key from an .ovpn file
# 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
# You can keep following these instructions here:
sed '1,/<ca>/d;/<\/ca>/,$d' $1 > $
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
Copy link

whycaress commented May 26, 2020

I have written a bash script that could split or merge OVPN config file. The code can be found at

didnt work

Copy link

labbots commented May 26, 2020

@whycaress could you please raise an issue on the repository with details of what exactly was not working and sample file with no personal information and key so I could test the script.

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