Skip to content

Instantly share code, notes, and snippets.

@chrobione
Last active January 14, 2019 19:01
Show Gist options
  • Save chrobione/0d394c5237b6d66e262daf7e02564ca8 to your computer and use it in GitHub Desktop.
Save chrobione/0d394c5237b6d66e262daf7e02564ca8 to your computer and use it in GitHub Desktop.
ovpn-maker.sh
#!/bin/sh
##
## Usage: ./ovpn-writer.sh SERVER CA_CERT CLIENT_CERT CLIENT_KEY > client.ovpn
## Orginial gist here https://gist.github.com/trovao/18e428b5a758df24455b
##
server=${1?"The server address is required"}
cacert=${2?"The path to the ca certificate file is required"}
client_cert=${3?"The path to the client certificate file is required"}
client_key=${4?"The path to the client private key file is required"}
cat << EOF
client
dev tun
remote ${server}
resolv-retry infinite
nobind
persist-key
persist-tun
ns-cert-type server
verb 1
keepalive 10 120
port 1194
proto udp
comp-lzo
remote-cert-tls server
<ca>
EOF
cat ${cacert}
cat << EOF
</ca>
<cert>
EOF
cat ${client_cert}
cat << EOF
</cert>
<key>
EOF
cat ${client_key}
cat << EOF
</key>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment