Before starting run:
Code: Select all
apt-get updateCode: Select all
apt-get -y upgradeDebian 10
Code: Select all
apt-get install mailxCode: Select all
sudo apt install bsd-mailxNow login as root user and go to root’s home directory by typing
Code: Select all
cd /rootOpen .bash_profile file with vi or nano editor
Code: Select all
sudo vi .bash_profileCode: Select all
sudo nano .bash_profileAdd 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_profileNow you get notified when someone or you acess the system, enjoy
