Last active
August 19, 2024 20:41
-
-
Save MJ111/830bd6d32833baf294e43ddaa967a05f to your computer and use it in GitHub Desktop.
openvpn cli add user script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: sh add_user.sh "username" "groupname" | |
# ref: https://openvpn.net/vpn-server-resources/managing-user-and-group-properties-from-command-line/ | |
# create user | |
sudo ./sacli --user $1 --key "type" --value "user_connect" UserPropPut | |
# add created user to specified group | |
sudo ./sacli --user $1 --key "conn_group" --value $2 UserPropPut | |
# generate random password | |
pw=$(openssl rand -base64 6) | |
# show generated password | |
echo "${pw}" | |
# set generated password to the user | |
sudo ./sacli --user $1 --new_pass $pw SetLocalPassword | |
# print users to make it sure | |
sudo ./sacli UserPropGet | |
# reload configuration to apply | |
sudo ./sacli start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment