1
0
mirror of synced 2025-02-16 20:13:19 +03:00

Create add_vpn_user.sh

Added a simple script for adding new vpn users
This commit is contained in:
Ernesto Serrano 2017-12-21 16:08:46 +01:00 committed by GitHub
parent 076406b80c
commit 93a66c380b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

25
extras/add_vpn_user.sh Normal file
View File

@ -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