Closed hestiacn closed 6 months ago
How to enable Aegis authentication in hestia server admin panel! Below is the command line processing configuration! Thanks to the developers! Please refer to!
#
user=$1
source /etc/hestiacp/hestia.conf
source $HESTIA/func/main.sh
source_conf "$HESTIA/conf/hestia.conf"
check_args '1' "$#" 'USER' is_format_valid 'user' 'system' is_object_valid 'user' 'USER' "$user"
check_hestia_demo_mode
source $USER_DATA/user.conf
if [ -n "$TWOFA" ]; then echo "Error: 2FA already enabled" exit "$E_EXISTS" fi
data=$($HESTIA_PHP $HESTIA/web/inc/2fa/secret.php)
IFS='-' read -r -a array <<< "$data" secret=${array[0]} qrcode=${array[1]}
update_user_value "$user" '$TWOFA' "$secret" update_user_value "$user" '$QRCODE' "$qrcode"
exit
Please correct it according to the command line processing, so that it can take effect!
Thanks for sharing your knowledge, I'm closing this though as this is not the place for this.
How to enable Aegis authentication in hestia server admin panel! Below is the command line processing configuration! Thanks to the developers! Please refer to!
!/bin/bash
info: add 2fa to existing user
options: USER
#
example: v-add-user-2fa admin
#
This function creates a new 2fa token for user.
----------------------------------------------------------
Variables & Functions
----------------------------------------------------------
Argument definition
user=$1
Includes
shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
load config file
source_conf "$HESTIA/conf/hestia.conf"
----------------------------------------------------------
Verifications
----------------------------------------------------------
check_args '1' "$#" 'USER' is_format_valid 'user' 'system' is_object_valid 'user' 'USER' "$user"
Perform verification if read-only mode is enabled
check_hestia_demo_mode
----------------------------------------------------------
Action
----------------------------------------------------------
Reading user values
source $USER_DATA/user.conf
Check if 2FA is already enabled
if [ -n "$TWOFA" ]; then echo "Error: 2FA already enabled" exit "$E_EXISTS" fi
Get secret and qr code from 2fa library
data=$($HESTIA_PHP $HESTIA/web/inc/2fa/secret.php)
Split to secret and qrcode using delimiter
IFS='-' read -r -a array <<< "$data" secret=${array[0]} qrcode=${array[1]}
Save the secret in user config (needs encryption?)
update_user_value "$user" '$TWOFA' "$secret" update_user_value "$user" '$QRCODE' "$qrcode"
----------------------------------------------------------
Hestia
----------------------------------------------------------
exit
Please correct it according to the command line processing, so that it can take effect!