Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Debian 8.5 x64
- # OpenVPN version 2.3.4
- # 06/07/2016
- # Check Arguments
- if [ $# -eq 0 ] || [ $# -gt 2 ]
- then
- /bin/echo ''
- /bin/echo 'This script is meant to be used in the following manner:'
- /bin/echo ''
- /bin/echo $0 '$1' '$2'
- /bin/echo ''
- /bin/echo ' ***where $1 = client#/android#/ios# depending on type and operating system of client***'
- /bin/echo ' ***where $2 = "remove" to revoke client and remove his files***'
- /bin/echo ''
- /bin/echo ''
- else
- # Check if client certs/keys/profiles already exist
- if [ $# -eq 1 ] && [ -e /etc/openvpn/easy-rsa-master/keys/$1/$1.ovpn ]
- then
- /etc/openvpn/easy-rsa-master/easyrsa3/easyrsa revoke $1
- /etc/openvpn/easy-rsa-master/easyrsa3/easyrsa gen-crl
- exit 1
- fi
- if [ "$2" != "remove" ] && [ -e /etc/openvpn/easy-rsa-master/keys/$1/$1.ovpn ]
- then
- /bin/echo ''
- /bin/echo 'This script is meant to be used in the following manner:'
- /bin/echo ''
- /bin/echo $0 '$1' '$2'
- /bin/echo ''
- /bin/echo ' ***where $1 = client#/android#/ios# depending on type and operating system of client***'
- /bin/echo ' ***where $2 = "remove" to revoke client and remove his files***'
- /bin/echo ''
- /bin/echo ''
- else
- if [ -e /etc/openvpn/easy-rsa-master/keys/$1/$1.ovpn ]
- then
- /etc/openvpn/easy-rsa-master/easyrsa3/easyrsa revoke $1
- /bin/rm /etc/openvpn/easy-rsa-master/easyrsa3/pki/issued/$1.crt
- /bin/rm /etc/openvpn/easy-rsa-master/easyrsa3/pki/private/$1.key
- /bin/rm /etc/openvpn/easy-rsa-master/easyrsa3/pki/reqs/$1.req
- /bin/rm -R /etc/openvpn/easy-rsa-master/keys/$1
- #/bin/sed -i "/\<CN=$1\>/d" /etc/openvpn/easy-rsa-master/easyrsa3/pki/index.txt
- /etc/openvpn/easy-rsa-master/easyrsa3/easyrsa gen-crl
- else
- /bin/echo "It seems that user $1 doesn't exists!!!"
- exit 1
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement