Hi, I'm trying to keep a log of the IP addresses used to log into my Raspberry Pi, both with a direct connection and through SSH, which I've managed to do. However, it's possible to have multiple SSH windows open from the same IP address, and I want to be able to distinguish between the sessions. By 'directly-connected', I mean the keyboard is plugged directly into the Pi. (Log in to hide this advertisement) In ~/.bashrc, used for tracking logins, I'm able to use $(tty) to get something in the format '/dev/pts/X'. In ~/.profile, I have: Code: trap '$HOME/.logout' 0 In ~/.logout, $(tty) returns 'not a tty' rather than the same value it returns on login, in ~/.bashrc. This must be because its value is undefined at the point of logout. Is there any way to get any form of unique identifier for both SSH and direct sessions, which can be retrieved in ~/.bashrc and ~/.logout? I'm also happy to have a system which creates a file which only that session can access, used to store a generated ID, if this is possible.