Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
deb13:otp_authenticator_for_php [2026/08/30 23:28] Bernard Condraudeb13:otp_authenticator_for_php [2026/08/30 23:47] (current) Bernard Condrau
Line 9: Line 9:
 source /home/user/html/pyotp-env/bin/activate</code> source /home/user/html/pyotp-env/bin/activate</code>
   - Install pyotp:<code>pip3 install pyotp</code>   - Install pyotp:<code>pip3 install pyotp</code>
-  - Check execution of pyotp:<code></code> +  - Create the python script ''/home/user/html/pyotp-env/otp.py'':<code># Python script to generate authenticator OTP
-  - Create the python script ''/home/user/html/otp.py'':<code># Python script to generate authenticator OTP+
 import pyotp import pyotp
  
Line 22: Line 21:
 current_code = totp.now() current_code = totp.now()
 print(current_code)</code> print(current_code)</code>
 +  - Check execution of pyotp:<code>python3 /home/user/html/pyotp-env/otp.py</code>
 +  - Create a bash script:<code>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</code>
 +  - Create a php web page which calls the script:<code>vim /home/user/html/otptest.php
 +<?php
 +$output = shell_exec('/home/bco/html/otp.sh');
 +echo $output;</code>
 +  - Give the scripts correct ownership and permissions:<code>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</code>
 +  - In Synology, you can check the OTP like this:<code>synootp username=user code=otp-code</code>