Successfull access log without IP address

xaras2

New Member
Mar 27, 2024
3
1
3
In my log file I have a problem, all successful logins not have ip address, all incorrect logins have ip addresses.
How can I add the IP address into log of successful accesses?

Code:
tail -f /var/log/syslog
Jun 13 14:01:00 proxmox-server pvedaemon[573436]: authentication failure; rhost=::ffff:192.168.1.10 user=test@pam msg=no such user ('test@pam')
Failed login have ip address

Code:
tail -f /var/log/syslog
Jun 13 13:06:53 proxmox-server pvedaemon[571457]: <root@pam> successful auth for user 'user@pam'
Successful not have ip address

syslog and journalctl are same
the log has changed since the last update

Thanks
 
Last edited:
Would be nice to have the IP address in the log file, especially for monitoring.
Yes, I can check the access.log file, but I'm not interested in which pages exactly they browsed around on (and a login could happen on any api-call) but rather the fact that a login has occurred.

The line is logged in pve-access-control/src/PVE/API2/AccessControl.pm.
The IP address is fetched a few lines above, for the auth failure:
my $clientip = $rpcenv->get_client_ip() || '';

So it's literally just changing the line

PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username'");

to

my $clientip = $rpcenv->get_client_ip() || '';
PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username', IP $clientip");
 
PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username', IP $clientip");
Have not tested your code, but that should probably be:
PVE::Cluster::log_msg('info', 'root@pam', "successful auth for user '$username', IP '$clientip'");
 
Then the IP address would be in quotes, but it wasn't on the failed auth message, so I didn't put it in quotes in the successful one. ;)
 
  • Like
Reactions: gfngfn256