From 9b763f6851a8f7e1a0e17b3de023e5e25ef3c7b7 Mon Sep 17 00:00:00 2001 From: shuangquan Date: Tue, 26 Sep 2017 15:07:41 +0800 Subject: [PATCH] res --- vpnadduser.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 vpnadduser.sh diff --git a/vpnadduser.sh b/vpnadduser.sh new file mode 100755 index 0000000..b53207b --- /dev/null +++ b/vpnadduser.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +VPN_USER="" +VPN_PASSWORD="" + +function read_user() +{ + + while [[ "$VPN_USER" == "" ]] + do + echo -e "VPN USER:\c" ; VPN_USER= ; read VPN_USER + done + + while [[ "$VPN_PASSWORD" == "" ]] + do + echo -e "VPN PASSWORD:\c" ; VPN_PASSWORD= ; read VPN_PASSWORD + done +} + +read_user + +PUBLIC_IP=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) +VPN_IPSEC_PSK=$(cat /etc/ipsec.secrets | grep PSK | awk '{print $5}') + +echo VPN_PASSWORD: $VPN_PASSWORD +echo VPN_USER: $VPN_USER +echo "\"$VPN_USER\" l2tpd \"$VPN_PASSWORD\" *" >> /etc/ppp/chap-secrets + + +VPN_PASSWORD_ENC=$(openssl passwd -1 "$VPN_PASSWORD") +echo VPN_PASSWORD_ENC: $VPN_PASSWORD_ENC +echo "$VPN_USER:$VPN_PASSWORD_ENC:xauth-psk" >> /etc/ipsec.d/passwd + + + +cat </dev/null +service xl2tpd restart 2>/dev/null +