Before starting run:
Code: Select all
apt-get update
Code: Select all
apt-get -y upgrade
Debian 10
Code: Select all
apt-get install mailx
Code: Select all
sudo apt install bsd-mailx
Now login as root user and go to root’s home directory by typing
Code: Select all
cd /root
Open .bash_profile file with vi or nano editor
Code: Select all
sudo vi .bash_profile
Code: Select all
sudo nano .bash_profile
Add the following whole line at the bottom of the file.
Replace “ServerName” with a hostname of your Server and change “[email protected]” with a your email address.
Code: Select all
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" [email protected]
Code: Select all
cd /home/admin/.bash_profile
Now you get notified when someone or you acess the system, enjoy