Get an email when somebody connects to ssh.
This script is called by sshrc
file and send an email notification every time
somebody make a successful connection by SSH.
ssh-notify writes an entry in a log file every time someone make a successful connection by SSH then it sends an email. In the config file, you can set a period of time to avoid receiving multiple times the same email. For example, if the last connection is less than 1 hour, you will not reveive another email.
bash
sendmail
- Download the last version of ssh-notify here
- Run
dpkg -i ssh-notify-X.X.X.deb
- Clone this repository:
git clone https://github.com/pruje/ssh-notify
- Update submodules:
git submodule update --init
- Run
install.sh
- Edit
/etc/ssh/ssh-notify.conf
- Add all users you want to monitor in
ssh-notify
group - (optionnal) If you want to secure access to the log file, you can enable the sudo mode in config
then add the following line in
/etc/sudoers.d/ssh-notify
:
%ssh-notify ALL = NOPASSWD:/path/to/ssh-notify/ssh-notify.sh
Run apt remove ssh-notify
Run uninstall.sh
ssh-notify is licensed under the MIT License. See LICENSE.md for the full license text.
Author: Jean Prunneaux https://jean.prunneaux.com
Source code: https://github.com/pruje/ssh-notify
Report a bug or request for a feature here.