This is question is an upgrade attempt of Find out which ssh key was used to access an account -- Some scripts for proper installation
Where I
- use
rsyslog
to generate separated log file, readable by groupuser
, - modify .bashrc for adding a
$SSH_USER_KEY
in user environment.
Unfortunately on systems using systemd
and journalctl
I have to manually install rsyslog
which are no more installed by default.
So yes, if I install rsyslog
package, I could resolve my problem, my scripts will run again but,
I wonder if there could exist some more appropriated (systemd) way for permitting user to see the hash of key used for the last connection.
Enable the "ExposeAuthInfo" option in your sshd configuration
The user will then get an
$SSH_USER_AUTH
environment variable, which points to a file containing the public key (or Kerberos principal name, or whatever else) that was used for authentication.This option is new in OpenSSH 7.6 (2017). If you're running an older version – install
rsyslog
.(Although in this situation, anything rsyslog does could also be achieved with a systemd .service that runs
ExecStart=journalctl -u sshd -f | grep public > /var/log/pubkeys
.)