[Proftpd-user] mod_sftp - logging remote IP address on authentication?

"John Stoffel" <[email protected]> Tue, 2 Jan 2024 17:09:17 -0500
Newsgroups gmane.network.proftpd.user
Message-ID <[email protected]>
I've been asked to monitor SFTP logins on a host using proftpd v1.3.7e 
running on Ubuntu 22.04.3 LTS.  I've noticed that when a user is
authenticated, the log message looks like this:

  2024-01-01 21:05:56,180 mod_sftp/1.0.1[206509]: user 'blah' authenticated via 'password' method

but you don't show the remove IP address associated with that login.
Looking at mod_sftp/auth.c, we can see the following lines in the function XXXXX


  if (session.auth_mech != NULL) {
    pr_log_debug(DEBUG2, "user '%s' authenticated by %s", user,
      session.auth_mech);
  }

  (void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
    "user '%s' authenticated via '%s' method", user, method);

  /* This allows for the %s response code LogFormat variable to be populated
   * in an AUTH ExtendedLog.
   */
  pr_response_add(R_230, "User %s logged in", user);
  pr_cmd_dispatch_phase(pass_cmd, POST_CMD, 0);
  pr_cmd_dispatch_phase(pass_cmd, LOG_CMD, 0);
  pr_response_clear(&resp_list);

  pr_cmd_dispatch_phase(cmd, POST_CMD, 0);
  pr_cmd_dispatch_phase(cmd, LOG_CMD, 0);


I haven't tried this yet, but would modifying the pr_log_writefile()
to look like this work?

  (void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
    "user '%s' authenticated via '%s' method from IP '%s'", user,
    method, session.c->remote_addr);

So it's trivial to figure out where the use logged in from?

I think I can also just look at the xferlog file and then
cross-correlate, but it's a pain in the ass and if the information is
already available at login, this would seem to make things simpler.  

My config looks like this for LOG directives:


proftpd.conf:TransferLog /var/log/proftpd/xferlog
proftpd.conf:SystemLog /var/log/proftpd/proftpd.log
proftpd.conf:SyslogLevel INFO
conf.d/sftp.conf:    SFTPLog          /var/log/proftpd/sftp.log



_______________________________________________
ProFTPD Users List   <[email protected]>
Unsubscribe problems?
http://www.proftpd.org/list-unsub.html