Snippets
Created by
aaa aaa
last modified
- Install mailx:
$ sudo aptitude install mailutils
- Add in
/etc/pam.d/sshd:
session optional pam_exec.so seteuid /etc/ssh/login-notify.sh
- Add the file:
$ sudo touch /etc/ssh/login-notify.sh
$ chmod +x /etc/ssh/login-notify.sh
- Edit the content:
#!/bin/sh
# Change these two lines:
sender="ssh@server.com"
recepient="root@anotherserver.com"
if [ "$PAM_TYPE" != "close_session" ]; then
host="`hostname`"
subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
message="`env`"
echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
fi
- Done
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.