Server several mail alarm settings of Linux system login mail alarm [II]

Source: Internet
Author: User

Linux System login Email alarm Settings

Strengthening the system account management is an important measure to enhance the security of the server, the enterprise information security accident often comes from inside the enterprise, the enterprise should pay attention to this piece, rationalize the distribution and use of account authority is an effective guarantee of enterprise information security. Today introduced under the Linux account login email alarm settings, to facilitate timely access to the account login situation, timely disposal of potential security threat risk.
Install MAILX on a Linux server and use RPM-QL MAILX to see if it is installed.
Use: Yum install Mailx–y

Installation Complete:

The Linux system will have one more mail command:

Next, configure mail:
Use: vim/etc/mail.rc
At the end of the mail.rc file, insert the following configuration, Wq save exit.

Then write a shell script, you can also put the script directly into the: Vim/etc/profile file (add to the last), this file when the user every time the login will be automatically loaded to execute once.
# #send Login warnning Mail
loginips=who -u am i |awk -F "[(|)]" ‘{print $2}‘
userlogin=whoami
Logintime=date +%Y-%m-%d" "%H:%M:%S
serverip=ifconfig |awk -F":" ‘NR==2{print $2}‘|awk ‘{print $1}‘
echo "Message for server $serverip $userlogin $logintime $loginips Login" |mail-r [email protected]-S "warnning" [email Protected

Wq Save exit.
Exit the system and re-login to the server to test the effect:

Here I configure the use of 163 of the Mail, on the phone remember to install an easy-faith app can immediately receive information to facilitate timely understanding of the situation.

Server several mail alarm settings of Linux system login mail alarm [II]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.