Creating Zip With VPN Client Keys and Configuration Files

Depends on server configuration, each OpenVPN client needs configuration file (client.conf for *nix and client.ovpn for windows), certificate authority (ca.crt), [optional] tls auth file (ta.key), user crt and key.

Typical OpenVPN client configuration file looks like (ca and ta files in «server» subdirectory):

remote <vpn server address>
port 1194
proto udp
dev tun
dev-type tun
ns-cert-type server
reneg-sec 86400
comp-lzo yes
verb 3
ca server/ca.crt
cert <user crt>
key <user key>
tls-auth server/ta.key 1

The following is tested on Ubuntu 12.04, but it will work (maybe with some modifications) in other linux distributions. Create new subdirectory «key-bundles» in /etc/openvpn/easy-rsa directory. Place there the following script «zip-key»:

cd keys
sed -s "s/^cert .*/cert ${NAME}.crt/g" -i client.conf
sed -s "s/^key .*/key ${NAME}.key/g" -i client.conf
cp client.conf client.ovpn
zip -r ../key-bundles/${NAME}.zip client.conf client.ovpn server ${NAME}.crt ${NAME}.key
cd -

You may need zip (sudo apt-get install zip) and make script executable (sudo chmod +x zip-key). I assume your VPN client configuration file is client.conf, ta.key and ca.crt are in /etc/openvpn/easy-rsa/keys/server directory. First and the only script argument is client key filename.