conf-99-basic_config_debian/etc/ssh/sshrc
Alban VIDAL 8ee75f3c5f Add alert by email for new ssh connexion
Signed-off-by: Alban VIDAL <alban.vidal@zordhak.fr>
2018-05-28 23:22:20 +02:00

15 lines
582 B
Plaintext

ip=`echo $SSH_CONNECTION | cut -d " " -f 1`
# Test if ip arealy present
if ! grep $ip /tmp/list_ip_ssh_$USER >/dev/null 2>&1
then
#logger -t ssh-wrapper $USER login from $ip
logger -t ssh-wrapper -p warning $USER login from unknown ip: $ip - $(host $ip|awk '{print $5}')
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
logger -t ssh-wrapper -p info $USER login from known ip: $ip
fi