the generator keeps track, so you can't generate.
-c CLIENT_HOST default is localhost. Else we ssh to root@CLIENT_HOST
-n CONFIG_NAME default is client
--s SCRIPT_PATH Use custom up/down script at PATH, copied to same path
- on client.
+-s SCRIPT_PATH Use custom up/down script at SCRIPT_PATH. copied to same path
+ on client, if client is not localhost.
Generate a client cert and config and install it on locally or on
CLIENT_HOST if given. Uses default config options, and expects be able
exit 1
fi
+port=$(echo '/^port/ {print $2}' | ssh root@$host awk -f - /etc/openvpn/server/$name.conf | tail -n1)
+
f=/etc/openvpn/client/$name.crt
if ! $shell "test -s $f"; then
client
dev tun
proto udp
-remote $host 1194
+remote $host $port
resolv-retry infinite
nobind
persist-key
persist-tun
-ca $name-ca.crt
+ca ca-$name.crt
cert $name.crt
key $name.key
# disabled for better performance
#comp-lzo
verb 3
-# This script will update local dns
-# to what the server sends, if it sends dns.
-script-security 2
-up "$script"
-down "$script"
-
# matching server config
cipher AES-256-CBC
-
# example config has the commented line, but this other thing looks stronger,
# and I've seen it in a vpn provider I trust
# ns-cert-type server
# The minimum of the client & server config is what is used by openvpn.
reneg-sec 432000
-tls-auth $name-ta.key 1
+tls-auth ta-$name.key 1
EOF
-if [[ $client_host ]] && $custom_script; then
- $shell "dd of=$script" <$script
- $shell "chmod +x $script"
+if [[ $script ]]; then
+ $shell "tee -a /etc/openvpn/client/$name.conf" <<EOF
+# This script will update local dns
+# to what the server sends, if it sends dns.
+script-security 2
+up "$script"
+down "$script"
+EOF
+
+ if [[ $client_host ]] && $custom_script; then
+ $shell "dd of=$script" <$script
+ $shell "chmod +x $script"
+ fi
fi
$shell 'cd /etc/openvpn; for f in client/*; do ln -sf $f .; done'