好日子,記錄特定成功的SSH登錄和disconections
我試圖記錄成功的ssh登錄和斷開特定用戶的時間。即我想在SSH連接建立和關閉時觸發一個bash腳本。
我一直在試圖理解不只是pam_exec多少成功的PAM.d模塊可能是我所期待的。
這裏是journalctl日誌當用戶我斷開後再重新連接:
May 31 00:47:31 myhostname.com sshd[11517]: Connection closed by 41.113.99.123
May 31 00:47:31 myhostname.com sshd[11517]: Transferred: sent 10160, received 12196 bytes
May 31 00:47:31 myhostname.com sshd[11517]: Closing connection to 41.113.99.123 port 24976
May 31 00:47:31 myhostname.com sshd[12377]: pam_unix(sshd:session): session closed for user myuser
May 31 00:47:31 myhostname.com systemd-logind[4406]: Removed session 24778.
May 31 00:47:52 myhostname.com sshd[11964]: Connection from 41.113.99.123 port 24989 on 178.79.130.104 port 22
May 31 00:47:55 myhostname.com sshd[11964]: Postponed publickey for myuser from 41.113.99.123 port 24989 ssh2 [preauth]
May 31 00:47:56 myhostname.com sshd[11964]: Accepted publickey for myuser from 41.113.99.123 port 24989 ssh2: RSA SHA256:R0y/xxxxxxxxxxxxxxxx/HuC6vZp/xxxxxxxxxxxxxx
May 31 00:47:56 myhostname.com sshd[11964]: pam_unix(sshd:session): session opened for user myuser by (uid=0)
May 31 00:47:56 myhostname.com systemd-logind[4406]: New session 24786 of user myuser.
May 31 00:47:56 myhostname.com systemd[1]: Started Session 24786 of user myuser.
May 31 00:47:57 myhostname.com sshd[11964]: User child is on pid 12009
是否有執行腳本的效率(可能PAM)的方式時,「會話」開和關的「myuser的? 如果可能的話,將有可能暴露相關的PID如圖所示的最後一行?
感謝