Hey,
Installed a server with Nyr script. Trying to run: client-connect '/usr/bin/python /etc/openvpn/connect.py'
The goal is to save connection info on those who connect to my server into a MySQL database.
OS: CentOS7
This works for testing when I connect to my own server:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb
import posix
db_server = 'localhost'
db_user = 'root'
db_pass = 'pass'
db_base = 'db'
db = MySQLdb.connect(db_server, db_user, db_pass, db_base)
with db:
c = db.cursor()
s = 'INSERT INTO clients (name,public_ip,vpn_ip) VALUES("client10","1.1.1.1","2.2.2.2");'
c.execute (s)
db.close()
But this does not:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb
import posix
db_server = 'localhost'
db_user = 'root'
db_pass = 'pass'
db_base = 'db'
db = MySQLdb.connect(db_server, db_user, db_pass, db_base)
with db:
c = db.cursor()
s = ('INSERT INTO clients (name,public_ip,vpn_ip) VALUES(%s, %s, %s)',(posix.environ['common_name'], posix.environ['trusted_ip'], posix.environ['ifconfig_pool_remote_ip']))
c.execute (s)
db.close()
Getting the following error:
SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
AUTH: Received control message: AUTH_FAILED
SIGUSR1[soft,auth-failure] received, process restarting
MANAGEMENT: >STATE:1551987668,RECONNECTING,auth-failure,,,,,
Restart pause, 5 second(s)
SIGTERM[hard,init_instance] received, process exiting
port 1194
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
user nobody
group nobody
dh dh.pem
auth SHA512
tls-auth ta.key 0
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
cipher AES-256-CBC
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem
mode server
script-security 2
client-connect '/usr/bin/python /etc/openvpn/connect.py'
client
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote xxx.xxx.xxx.xxx 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
setenv opt block-outside-dns
key-direction 1
verb 3
Is there any other way to save info about who connects to my server?
I would be eternally grateful if someone could help!