Since OpenSSH 7.2 it is possible to identify sessions within log files as session-related log entries include the clients port. Right now I don't see a good way to correlate output of PAM modules to the session as only the clients host (PAM_RHOST) is exported to the PAM environment. If the clients port was accessible within PAM it can be included in log messages and thus correlated to a session. Export can be e.g. done through pam_set_item() or pam_putenv().
Created attachment 3213 [details] set SSH_CONNECTION in PAM environment Unfortunately it can't be done using pam_set_item() as there is no equivalent key to PAM_RHOST for the port number. That's a pity as that would be the most natural way to supply this information. So this sets SSH_CONNECTION in the PAM environment, identically to what should be later set in the user enviornment. This contains the full 4-tuple describing the connection.
This has been committed and will be in the openssh-8.0 release
closing resolved bugs as of 8.6p1 release