====== OTP authenticator for php ====== - Create a python virtual environment in a location your web server can access:cd /home/user/html mkdir -p /home/user/html/pyotp-env sudo chown user:www-data /home/user/html/pyotp-env sudo chmod 770 /home/user/html/pyotp-env - Create a virtual environment as apache2 user and activate it:sudo -s -u www-data python3 -m venv /home/user/html/pyotp-env source /home/user/html/pyotp-env/bin/activate - Install pyotp:pip3 install pyotp - Create the python script ''/home/user/html/pyotp-env/otp.py'':# Python script to generate authenticator OTP import pyotp # Your Base32 secret key (provided when setting up 2FA) secret = "ABCDE1FGHIJK2LMN" # Initialize TOTP totp = pyotp.TOTP(secret) # Generate the current 6-digit code current_code = totp.now() print(current_code) - Check execution of pyotp:python3 /home/user/html/pyotp-env/otp.py - Create a bash script:vim /home/user/html/otp.sh #!/bin/bash source /home/user/html/pyotp-env/bin/activate python3 /home/user/html/pyotp-env/otp.py deactivate exit 0 - Create a php web page which calls the script:vim /home/user/html/otptest.php - Give the scripts correct ownership and permissions:sudo chown www-data:www-data /home/bco/html/pyotp-env/otp.py sudo chown www-data:www-data /home/bco/html/otp.sh sudo chmod +x /home/bco/html/otp.sh - In Synology, you can check the OTP like this:synootp username=user code=otp-code