In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to set up email alerts for SSH login on Linux. The content is very detailed. Interested friends can refer to it for reference. I hope it can help you.
What does the.bashrc file do?
The.bashrc file is a script that is executed whenever a new terminal session is started interactively.
1)How to enable email alerts for root
Log in as root and add the following one-line script to the root " .bashrc" file to do this:
[root@localhost ~]# vim /root/.bashrc echo 'ALERT - SSH root shell access found on '$HOSTNAME' on:' `date` `who` | mail -s "Alert: SSH root shell access" root@localhost
Execute the following order to give effect to the order:
[root@localhost ~]# source .bashrc
When this is done, log in as root. You will receive email alerts similar to the following.
Change root@localhost in the code to the mailbox you use to receive mail.
2)How to enable email alerts for specific users
The following script needs to be added to the specified user's.bashrc file:
[root@localhost ~]# vim /home/bob/.bashrc echo 'ALERT - '$USER' shell access found on '$HOSTNAME' on:' `date` `who` | mail -s "Alert: User shell access" root@localhost
Change root@localhost in the code to the mailbox you use to receive mail.
The prompt after login is as follows:
3)How to enable email alerts for all users
Enabling email alerts for all users is similar to the configuration above. However, you need to add the following script to the last line of the/etc/bashrc file:
[root@localhost ~]# vim /etc/bashrc echo 'ALERT - '$USER' shell access found on '$HOSTNAME' on:' `date` `who` | mail -s "Alert: User shell access" root@localhost
About how to set up email alerts for SSH login on Linux to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.