Split .ovpn file to ca, cert and key with awk

With the following awk commands one can simply extract ca, cert and key files:

awk '/<ca>/{flag=1;next}/<\/ca>/{flag=0}flag' client.ovpn > server-ca.pem
awk '/<cert>/{flag=1;next}/<\/cert>/{flag=0}flag' client.ovpn > server.crt
awk '/<key>/{flag=1;next}/<\/key>/{flag=0}flag' client.ovpn > server.key
Bookmark the permalink.

3 Responses to Split .ovpn file to ca, cert and key with awk

  1. In a word… Indispensible. I work with OpenVPN a lot and this little ditty is going in a bash script – Many thanks 😀

  2. Daniel says:

    How do you do this?

    • Donjon says:

      Install awk on whatever machine your running, open a command line and run the commands on your respective .ovpn file

Leave a Reply

Your email address will not be published. Required fields are marked *