OpenVPN add client bash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#!/bin/bash #script to create a openvpn user if [ -z "$1" ]; then echo "Usage: $0 <vpn -user-name>" exit 1 fi if [[ ! "$1" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "Invalid VPN user name" exit 1 fi if [ `whoami` != "root" ]; then echo "Must run as root!" exit 1 fi if [ -f "$1.ovpn" ]; then echo "User $1 already exists!" exit 1 fi #pushd `dirname $0` >/dev/null SCRIPTDIR=/etc/openvpn/easy-rsa if [ ! -d "$SCRIPTDIR" ]; then echo "$SCRIPTDIR not found, check again!" exit 1 fi pushd $SCRIPTDIR >/dev/null echo "=======================" echo "Your will need to enter PEM pass phrase, and MUST left challeng password blank!" echo . ./vars ./build-key-pass $1 echo "=======================" echo "openssl des3 encryption, your can use the same password as before." echo openssl rsa -in keys/$1.key -des3 -out keys/$1.3des.key echo "=======================" echo "generate Diffie-Hellman key exchange" echo ./build-dh if [ -f "keys/ta.key" ]; then echo "HMAC key exists already!" else echo "=======================" echo "generate the static HMAC key" echo openvpn --genkey --secret keys/ta.key fi echo "=======================" echo "make ovpn" echo pushd $SCRIPTDIR/keys/ >/dev/null bash MakeOVPN.sh $1 echo "===== Done! ====" echo "Your can mail the $1.ovpn to your friend!" </vpn> |
本作品采用创作共用版权协议, 要求署名、非商业用途和保持一致. 转载本站内容必须也遵循署名-非商业用途-保持一致的创作共用协议.
发表回复