From 93a66c380b8f5c6db6025d49212d9508e060964f Mon Sep 17 00:00:00 2001 From: Ernesto Serrano Date: Thu, 21 Dec 2017 16:08:46 +0100 Subject: [PATCH] Create add_vpn_user.sh Added a simple script for adding new vpn users --- extras/add_vpn_user.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 extras/add_vpn_user.sh diff --git a/extras/add_vpn_user.sh b/extras/add_vpn_user.sh new file mode 100644 index 0000000..ddbd548 --- /dev/null +++ b/extras/add_vpn_user.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Script for adding a new vpn user +# Usage: ./add_vpn_user.sh username pa$$word +# + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +if [[ $# -ne 2 ]] ; then + echo 'Usage: add_vpn_user.sh username pa$$word' + exit 0 +fi + +echo "Adding user..." + +echo "\"$1\" l2tpd \"$2\" *" | tee -a /etc/ppp/chap-secrets > /dev/null +echo "$1:$(openssl passwd -1 $2):xauth-psk" | tee -a /etc/ipsec.d/passwd > /dev/null + +echo "Restarting vpn service..." + +service ipsec restart +service xl2tpd restart