Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 607
  • Last Modified:

email alert on root login in centos

i want to setup email alert on ssh root login
i read few forum about this

vi .bash_profile
Scroll down to the end of the file and add the following line:

echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" user@example.com

but it not working then few people suggest that .bashrc is the file in which i need to add the line
but in my centos root directory no file .bashrc

how can i get the email alert??
  • 2
1 Solution
Sikhumbuzo NtsadaSenior IT TechnicianCommented:
Even if you do an "ls -a" you still cannot see it?

can you go ahead and type "vi .bashrc"
It's hidden, it should be there.
udayrathorAuthor Commented:
yes even after ls -a id not showing

.  ..  .bash_history  .bash_profile  .custombuild  .rnd  setup.sh  .ssh
Sikhumbuzo NtsadaSenior IT TechnicianCommented:
..Okay, I'm not infront of Centos machine now, it will be difficult to check.

Also see "/etc/bashrc"
If /root/.bashrc doesn't exist, creating one is trivial. Just edit or create the file (such as via vi /root/.bashrc) and it should be executed on login, unless you're configured to prevent it.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now