From ff7494041582ada6ff5be3b5c0ab9f09bb2d052d Mon Sep 17 00:00:00 2001 From: Bonhomme Date: Thu, 9 Jul 2020 11:49:58 +0200 Subject: [PATCH] Simple script to add users passed as arguments --- add-usr.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 add-usr.sh diff --git a/add-usr.sh b/add-usr.sh new file mode 100644 index 0000000..9147953 --- /dev/null +++ b/add-usr.sh @@ -0,0 +1,34 @@ +#!/bin/bash + + +new_client () { +# Generates the custom client.ovpn +{ +NEW_CLIENT=$1 +cat /etc/openvpn/server/client-common.txt + echo "" + cat /etc/openvpn/server/easy-rsa/pki/ca.crt + echo "" + echo "" + sed -ne '/BEGIN CERTIFICATE/,$ p' /etc/openvpn/server/easy-rsa/pki/issued/$NEW_CLIENT.crt + echo "" + echo "" + cat /etc/openvpn/server/easy-rsa/pki/private/$NEW_CLIENT.key + echo "" + echo "" + sed -ne '/BEGIN OpenVPN Static key/,$ p' /etc/openvpn/server/tc.key + echo "" + } > /etc/openvpn/client/$NEW_CLIENT.ovpn +} + + +for NEW_USER in "$@" +do +echo "New client certification generation for: " $NEW_USER +bash /etc/openvpn/server/easy-rsa/easyrsa build-client-full $NEW_USER nopass + +new_client $NEW_USER + +done + +