Hi,
I've managed to write a script which logs whether or not a connection is via SSH or direct, along with the IP address of the connecting party, but I can't get it to work the same on logout.
I created a script at ~/.logout which is called via
in ~/.profile. The script is called, but it seems $SSH_CONNECTION is undefined at that point, so it's reporting SSH connections as not via SSH.
~/.logout:
I can only imagine that the SSH connection is closed by the time this script is run. Is there any way around this?
I've managed to write a script which logs whether or not a connection is via SSH or direct, along with the IP address of the connecting party, but I can't get it to work the same on logout.
I created a script at ~/.logout which is called via
Code:
trap '$HOME/.logout' 0
~/.logout:
Code:
#!/bin/sh
if [[ -n $SSH_CONNECTION ]] ; then
(/var/www/html/logging/logout-report ssh $(echo $SSH_CONNECTION | awk '{print $1}') &)
else
(/var/www/html/logging/logout-report direct &)
fi
exit 0
I can only imagine that the SSH connection is closed by the time this script is run. Is there any way around this?