How to Get Linux Server Sends Email Alert on Root Login如何获得Linux服务器发送电子邮件警报root登录
To improve the security of the server, especially web server which exposes to the Internet and possible worldwide hackers, it’s best to enable server to automatically send a notification email to predefined email address everytime someone logs in as root to the host.为了提高安全性的服务器, Web服务器尤其是其中暴露的互联网和全世界的黑客有可能,最好使服务器自动发送通知邮件到预定的电子邮件地址记录每次有人在根向东道国。 To configure the automatic email alert notification to a default email address on each incident of root log on on the server, use the following guide.要配置自动发出的电子邮件警告通知预设的电子邮件地址,每起事故的根源登录的服务器上,请使用下面的指南。
- Login to the server via SSH using as root ID.登录到服务器通过SSH使用根编号。
- Ensure that you’re at home directory of root.确保你在家里的根目录。 The open up the .bash_profile for editing using pico or vi by typing one of the following commands at command shell line:在开放。 bash_profile编辑使用峰或vi输入下列命令之一在命令行:
pico .bash_profile峰。 bash_profile
vi .bash_profile六。 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.comReplace user@email.com with the actual email account address that you want to the root access alert notification been sent to.替换user@email.com与实际的电子邮件帐户地址,您要访问的根源警报通知被送往。 Note that you can change the text contains in the email alert too.请注意,您可以改变文字包含在电子邮件中也警告。 The text starting with first ALERT is written as email body, and you can add in other info such as host name or change the wordings.文字开始的第一次书面通知的目的是作为电子邮件的身体,您可以添加其他信息,如主机名称或变更的字眼。 The second Alert is the email title which you can change to your own too.第二个警示是电子邮件标题,您可以改变自己太多。
Now logout and login again as root, you should receive an email alert at your inbox.现在,注销和重新登录为根,你应该收到一封电子邮件,提醒您的收件箱。 The security trick should works on most popular flavor of Linux such as RedHat, CentOS, Ubuntu, FreeBSD and etc.安全诱骗应当工程最流行的风味的Linux ,如红帽, CentOS , Ubuntu的, FreeBSD和等
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明:这是一台机器翻译网页这是“原样”提供,无保修。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原文的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at共享和贡献或获得技术支持和帮助 My Digital Life Forums 我的数字生活论坛 . 。
Related Articles相关文章
- Disable Direct Root Login and User Access via SSH to Server禁用直接根登录和用户通过SSH访问服务器
- Reset the Root Password of MySQL Server复位根用户密码的MySQL服务器
- Sign Up as @Gmail.com Instead Of @GoogleMail.com As Email Address and Login注册as@Gmail.com不是Of@GoogleMail.com电子邮件地址和登录
- Novell SUSE Linux Enterprise Server 10 Reviews Novell公司的SUSE Linux Enterprise Server 10评语
- How to Check Memory Usage in Linux based Server如何检查记忆体使用量在基于Linux的服务器
- How to Change or Spoof MAC Address in Windows XP, Vista, Server 2003/2008, Mac OS X, Unix and Linux如何更改或欺骗性MAC地址在Windows XP , Vista系统,服务器二千○八分之二千○三时, Mac OS X , Unix和Linux
- Open, Extract and Convert DAA, ISO and BIN Files in Linux with Free PowerISO for Linux打开,提取和转换的DAA ,国际标准化组织和本文件在Linux与自由PowerISO为Linux
- Reveal and Recover Windows NT, 2000, XP, 2003 and Longhorn Login (including Administrator) Username and Password with Login Recovery揭露和恢复的Windows NT , 2000 , XP , 2003和Longhorn的登录(包括管理员)的用户名和密码登录复苏与
- Remove ESET NOD32 Checked Email Confirmation Tag Message in Email ESET 32移除检查电子邮件确认标记消息在电子邮件
- Unmirror rootvg (Root Volume Group) in AIX Unmirror rootvg (根卷组)中的AIX

































August 12th, 2007 03:10 2007年八月12日3点10分
[...] Linux - wysyłanie maila o logowaniu na konto roota Bardzo użyteczny skrypcik [...] [...] Linux操作系统-w ysyłaniem ailaö l ogowaniu缺帐户r ootaB ardzou żytecznys krypcik[ ...]
May 3rd, 2008 05:43 2008年5月3号05:43
‘who -m’ makes the output much cleaner when using this on a system that has multiple users logged on… '谁米,使输出更清洁时,使用此系统上有多个用户登录...
-m reports only hostname and user associated with stdin terminal米的报告仅主机和用户相关的标准输入终端
November 1st, 2008 03:06 08年11月1号03:06
This works for root login or su - from a user login.此工程root登录或洙-从一个用户登录。
How can I implement it that will work also for “su” only?我该如何执行,将工作还为“秀”吗? Right now since the path will change with su instead of su - it will not send an email if someone is not using the “-” after the su.现在因为道路将改变与苏不是洙-它不会发送电子邮件,如果有人不使用“ - ”后洙。 Thanks.谢谢。