Skip to content

Instantly share code, notes, and snippets.

@Siot
Last active July 31, 2018 09:29
Show Gist options
  • Save Siot/9248473 to your computer and use it in GitHub Desktop.
Save Siot/9248473 to your computer and use it in GitHub Desktop.
.ovpn creator script
#!/bin/bash
ip="1.2.3.4"
port="1194"
proto="udp"
############################
client=$1
ca="ca.crt"
cert=$client".crt"
key=$client".key"
tlsauth="ta.key"
ovpndest=$client".ovpn"
cat > $ovpndest << EOF
client
proto $proto
port $port
remote $ip
dev tun
nobind
resolv-retry infinite
persist-key
persist-tun
ns-cert-type server
comp-lzo
verb 3
key-direction 1
EOF
echo "<ca>" >> $ovpndest
awk /BEGIN/,/END/ < ./$ca >> $ovpndest
echo "</ca>" >> $ovpndest
echo "<cert>" >> $ovpndest
awk /BEGIN/,/END/ < ./$cert >> $ovpndest
echo "</cert>" >> $ovpndest
echo "<key>" >> $ovpndest
awk /BEGIN/,/END/ < ./$key >> $ovpndest
echo "</key>" >> $ovpndest
echo "<tls-auth>" >> $ovpndest
awk /BEGIN/,/END/ < ./$tlsauth >> $ovpndest
echo "</tls-auth>" >> $ovpndest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment