I need to be notified by email when my Ubuntu server is remoted via SSH connection. If it is possible, how can we do it?
You should be able to do so with a rule in
You can get more detail from a script run from
If you don't need immediate notification, the
EDIT: Ubuntu uses the incompatible
Notes: Backslash notation can be used to wrap lines as above. Substitution characters are documented in the
Your best bet is to set up a script to watch the log file.
I'm on my phone at the moment, but Check /var/log/access.log
The log is on auth.log, you can do a
To actualy send the mail you could install SSMTP, edit it's config as follows:
Create a text file with the message body as follows:
To add the content you could do:
and then run
Another OP said you might want a notification each time it happens, you coud do something LIKE this:
create an script with
Mailcontents should include the addresses as stated before, the script code has not been checked to be valid, consider it pseudocode.