From 8a265289a8c6a90e217421d584f862fc9185a81d Mon Sep 17 00:00:00 2001 From: Alban Vidal Date: Sun, 7 Apr 2019 11:35:45 +0200 Subject: [PATCH] Update comment Signed-off-by: Alban Vidal --- etc/ssh/sshrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etc/ssh/sshrc b/etc/ssh/sshrc index e9ea776..0b09d2b 100644 --- a/etc/ssh/sshrc +++ b/etc/ssh/sshrc @@ -1,14 +1,18 @@ +# Extract ip address ip=`echo $SSH_CONNECTION | cut -d " " -f 1` -# Test if ip arealy present +# Test if the ip address is already present if ! grep $ip /tmp/list_ip_ssh_$USER >/dev/null 2>&1 then - #logger -t ssh-wrapper $USER login from $ip + # New ip address + # Write to log logger -t ssh-wrapper -p warning $USER login from unknown ip: $ip - $(host $ip|awk '{print $5}') + # Send by mail echo "User $USER just logged in from $ip - $(host $ip|awk '{print $5}')" |mail -s "New SSH Login to $USER in $(hostname)" __ALERT_EMAIL__ # add the ip in temporary list echo "$(date) - $ip" >> /tmp/list_ip_ssh_$USER else + # IP address already present in temporary file logger -t ssh-wrapper -p info $USER login from known ip: $ip fi