Skip to content

Instantly share code, notes, and snippets.

@DominikBucher12
Created March 21, 2018 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominikBucher12/b61310ce0daae7c014ca83dec81e927f to your computer and use it in GitHub Desktop.
Save DominikBucher12/b61310ce0daae7c014ca83dec81e927f to your computer and use it in GitHub Desktop.
Simple script for transforming Tunnelblick VPN configuration into OpenVPN configuration.
#!/bin/bash
# This is just very simple script (No error checking) for transformating the
# tunnelblick VPN configuration with multiple files
# into one file which contains the keys and certs in tags instead of separate file.
# This is good for example for using openVPN in Mobile devices, where you cannot put the Tunnelblick
# configuration file.
# Usage:
# - 1. Open terminal and change your directory to
# the one containing ca.crt, username.crt, username.key and vpn.whatever.cc.conf
# - 2. Run the script from within, do not forget to add parameter username
# (According to this the script knows which files to take and insert into the file...)
#. 3. When done, you will end up with config.ovpn file which contains all the content of files inside tags...
# Note: The awk deletes the paths in the configuration so you do not need to delete them yourself.
# We need to know the username so we get the certificates and key from the files
USERNAME=$1
# We start by deleting the crt/key achieving from files from the configuration
# and insert it into new file config.ovpn
awk '!/crt|key/' *.conf > config.ovpn
# We insert the <ca> tag and keep doing the actions with the other files...
echo "<ca>" >> config.ovpn
cat ca.crt >> config.ovpn
echo "</ca>" >> config.ovpn
# Get the cert...
echo "<cert>" >> config.ovpn
cat $USERNAME.crt >> config.ovpn
echo "</cert>" >> config.ovpn
# And the key...
echo "<key>" >> config.ovpn
cat $USERNAME.key >> config.ovpn
echo "</key>" >> config.ovpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment