# 小小修改一下vars变量文件 sed -i 's/^export KEY_COUNTRY.*/export KEY_COUNTRY="CN"/g' easy-rsa-old-master/easy-rsa/2.0/vars sed -i 's/^export KEY_PROVINCE.*/export KEY_PROVINCE="Beijing"/g' easy-rsa-old-master/easy-rsa/2.0/vars sed -i 's/^export KEY_CITY.*/export KEY_CITY="Beijing"/g' easy-rsa-old-master/easy-rsa/2.0/vars cd easy-rsa-old-master/easy-rsa/2.0/ source vars ./clean-all
sudo tee > /etc/openvpn/server/auth_pass.sh <<EOF #!/bin/sh # checkpsw.sh (C) 2004 Mathias Sundman <mathias@openvpn.se> # # This script authenticates OpenVPN users against a plain text file. # The passfile should contain one row per user with the username first, # followed by one or more spaces or tabs, and then the password. PASSFILE="/etc/openvpn/server/pass_file" LOG_FILE="/etc/openvpn/server/openvpn-password.log" TIME_STAMP=$(date "+%Y-%m-%d %T") # Check if the password file is readable if [ ! -r "${PASSFILE}" ]; then echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> "${LOG_FILE}" exit 1 fi # Extract the correct password for the given username CORRECT_PASSWORD=$(awk -v user="${username}" '!/^;/ && !/^#/ && $1 == user {print $2; exit}' "${PASSFILE}") # Check if the user exists in the password file if [ "${CORRECT_PASSWORD}" = "" ]; then echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> "${LOG_FILE}" exit 1 fi # Check if the provided password matches the stored password if [ "${password}" = "${CORRECT_PASSWORD}" ]; then echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> "${LOG_FILE}" exit 0 else echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> "${LOG_FILE}" exit 1 fi EOF chmod +x auth_pass.sh echo"test 123456" >> /etc/openvpn/server/pass_file