Re: Client history

Peter Davis via Openvpn-users <[email protected]>
Newsgroups gmane.network.openvpn.user
Message-ID <8Rr5e3C0gmqxDmQ1x3RIic7rkyZklLBaz16ho5Al-7BkmRnpkVIzTq34iRX-Mk8WEqSlkW7rtiojG-qD7A7XNoxEtLuY6IK0IrdMsTb3hOM=@proton.me>
> On Friday, February 23rd, 2024 at 12:36 PM, Bo Berglund <[email protected]> wrote:

> On Fri, 23 Feb 2024 08:12:47 +0000, Peter Davis via Openvpn-users
> [email protected] wrote:
> 
> > Hi,
> > Thanks again.
> > You right. Logs are under "/tmp/systemd-private-0b76fd773c1b491090b475708960936b-openvpn\@server.service-kEyUKj/tmp/Connections.log".
> > 
> > Why is nothing written to the file when I create it in the "/var/log/openvpn directory"?
> > 
> > # ls -l /var/log/openvpn/
> > total 40
> > -rw-r--r-- 1 root root 0 Feb 23 10:16 Connections.log
> > -rw------- 1 root root 603 Feb 23 11:41 openvpn-status.log
> > -rw------- 1 root root 30242 Feb 23 11:40 openvpn.log
> 
> 
> Why don't you (at least for testing that the script works) do as follows:
> 
> /etc/openvpn/server/server.conf:
> --------------------------------
> script-security 2
> client-connect /etc/openvpn/scripts/server-events.sh
> client-disconnect /etc/openvpn/scripts/server-events.sh
> 
> /etc/openvpn/scripts/server-events.sh:
> --------------------------------------
> # Log file path
> LOG_FILE="/etc/openvpn/log/server-events.log"
> 
> (Notice case of the identifier!, see below)
> 
> On the command line:
> --------------------
> if you do not yet have a dir /etc/openvpn/log then do:
> 
> sudo mkdir /etc/openvpn/log
> 
> DO NOT create the log file there, let the script do it for you so the
> permissions will be correctly set!
> 
> Now restart the openvpn server and make a connect attempt, then check the
> /etc/openvpn/log dir for the logfile.
> 
> IMPORTANT:
> ==========
> And please note that all identifiers are case sensitive in Linux so the
> entry in your earlier post:
> 
> log_file="/tmp/Connections.log"
> 
> is NOT compatible with the script as I had written it where the variable
> LOG_FILE is used...
> 
> 
> --
> Bo Berglund
> Developer in Sweden
> 
> 
> 
> _______________________________________________
> Openvpn-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openvpn-users

Hello,
Sorry, I forgot to tell you that you script never worked!
I found another script as below:

log_file="/tmp/Connections.log"
# Vars used:
date_now="$(date +'%F-%H:%M')"
line="User '$common_name' \
at $date_now \
using $ifconfig_pool_remote_ip \
from ${trusted_ip}:${trusted_port}"
# Append to the log
echo "$line" >> "$log_file"
# END User Connect Accounting
exit 0

But this script cannot write anything in "/tmp/Connections.log" file, but under the directory "/tmp/systemd-private-0b76fd773c1b491090b475708960936b-openvpn@server.service" it can write the information correctly.

I am back to your script. I did:

# mkdir /etc/openvpn/Log/

Then, changed the script as below:

LOG_FILE="/etc/openvpn/Log/Connections.log"

Then:

# systemctl restart openvpn

But:

# ls /etc/openvpn/Log/
#

No files have been created.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.