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]