Make OpenVPN username case insensitive
This commit is contained in:
parent
e6f33e3015
commit
f35d41bc3a
@ -21,15 +21,15 @@ if [ -f "/etc/openvpn/easy-rsa/pki/issued/$CLIENT_NAME.crt" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if grep -q "^auth-user-pass-verify" "/etc/openvpn/myserver.conf"; then
|
if grep -q "^auth-user-pass-verify" "/etc/openvpn/myserver.conf"; then
|
||||||
read -e -p "Enter username: " -i "$CLIENT_USERNAME" CLIENT_USERNAME
|
read -e -p "Enter username: " -i "$CLIENT_NAME" CLIENT_USERNAME
|
||||||
if grep -q "^$CLIENT_USERNAME" "/etc/openvpn/credentials"; then
|
if grep -i -q "^$CLIENT_USERNAME" "/etc/openvpn/credentials"; then
|
||||||
echo "Username $CLIENT_USERNAME already exists"
|
echo "Username $CLIENT_USERNAME already exists"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
read -e -p "Enter password: " -i "$CLIENT_PASSWORD" CLIENT_PASSWORD
|
read -e -p "Enter password: " -i "$CLIENT_PASSWORD" CLIENT_PASSWORD
|
||||||
CLIENT_PASSWORD_HASH=$(echo -n "$CLIENT_PASSWORD" | sha256sum | awk '{print $1}')
|
CLIENT_PASSWORD_HASH=$(echo -n "$CLIENT_PASSWORD" | sha256sum | awk '{print $1}')
|
||||||
echo "$CLIENT_USERNAME:$CLIENT_PASSWORD_HASH:$CLIENT_NAME" >> "/etc/openvpn/credentials"
|
echo "$CLIENT_USERNAME:$CLIENT_PASSWORD_HASH:$CLIENT_NAME" >> "/etc/openvpn/credentials"
|
||||||
EXTRA_CONFIG = "auth-user-pass"
|
EXTRA_CONFIG="auth-user-pass"
|
||||||
fi
|
fi
|
||||||
read -e -p "Use static IP for this client? VPN subnet is $VPN_SUBNET (Leave empty for dynamic): " -i "" CLIENT_IP
|
read -e -p "Use static IP for this client? VPN subnet is $VPN_SUBNET (Leave empty for dynamic): " -i "" CLIENT_IP
|
||||||
if [ ! -z "${CLIENT_IP}" ]; then
|
if [ ! -z "${CLIENT_IP}" ]; then
|
||||||
|
@ -144,15 +144,15 @@ if [ -f "/etc/openvpn/easy-rsa/pki/issued/$CLIENT_NAME.crt" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if grep -q "^auth-user-pass-verify" "/etc/openvpn/myserver.conf"; then
|
if grep -q "^auth-user-pass-verify" "/etc/openvpn/myserver.conf"; then
|
||||||
read -e -p "Enter username: " -i "$CLIENT_USERNAME" CLIENT_USERNAME
|
read -e -p "Enter username: " -i "$CLIENT_NAME" CLIENT_USERNAME
|
||||||
if grep -q "^$CLIENT_USERNAME" "/etc/openvpn/credentials"; then
|
if grep -i -q "^$CLIENT_USERNAME" "/etc/openvpn/credentials"; then
|
||||||
echo "Username $CLIENT_USERNAME already exists"
|
echo "Username $CLIENT_USERNAME already exists"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
read -e -p "Enter password: " -i "$CLIENT_PASSWORD" CLIENT_PASSWORD
|
read -e -p "Enter password: " -i "$CLIENT_PASSWORD" CLIENT_PASSWORD
|
||||||
CLIENT_PASSWORD_HASH=$(echo -n "$CLIENT_PASSWORD" | sha256sum | awk '{print $1}')
|
CLIENT_PASSWORD_HASH=$(echo -n "$CLIENT_PASSWORD" | sha256sum | awk '{print $1}')
|
||||||
echo "$CLIENT_USERNAME:$CLIENT_PASSWORD_HASH:$CLIENT_NAME" >> "/etc/openvpn/credentials"
|
echo "$CLIENT_USERNAME:$CLIENT_PASSWORD_HASH:$CLIENT_NAME" >> "/etc/openvpn/credentials"
|
||||||
EXTRA_CONFIG = "auth-user-pass"
|
EXTRA_CONFIG="auth-user-pass"
|
||||||
fi
|
fi
|
||||||
read -e -p "Use static IP for this client? VPN subnet is $VPN_SUBNET (Leave empty for dynamic): " -i "" CLIENT_IP
|
read -e -p "Use static IP for this client? VPN subnet is $VPN_SUBNET (Leave empty for dynamic): " -i "" CLIENT_IP
|
||||||
if [ ! -z "${CLIENT_IP}" ]; then
|
if [ ! -z "${CLIENT_IP}" ]; then
|
||||||
@ -217,7 +217,7 @@ readarray -t lines < $1
|
|||||||
username=${lines[0]}
|
username=${lines[0]}
|
||||||
password=${lines[1]}
|
password=${lines[1]}
|
||||||
password_hash=$(echo -n "$password" | sha256sum | awk '{print $1}')
|
password_hash=$(echo -n "$password" | sha256sum | awk '{print $1}')
|
||||||
if grep -q "^$username:$password_hash:" "/etc/openvpn/credentials"; then
|
if grep -i -q "^$username:$password_hash:" "/etc/openvpn/credentials"; then
|
||||||
exit 0 # Authentication success
|
exit 0 # Authentication success
|
||||||
else
|
else
|
||||||
exit 1 # Authentication failed
|
exit 1 # Authentication failed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user