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.要配置自动发出的电子邮件警告通知预设的电子邮件地址,每起事故的根源登录的服务器上,请使用下面的指南。

  1. Login to the server via SSH using as root ID.登录到服务器通过SSH使用根编号。
  2. 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

  3. 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

    Replace 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 我的数字生活论坛 .



3 Responses to “How to Get Linux Server Sends Email Alert on Root Login”三答复“如何获得Linux服务器发送电子邮件警报根登录”

  1. Linux - wysyłanie maila o logowaniu na konto roota « Barni.LOG Linux操作系统-w ysyłaniem ailaö l ogowaniu缺帐户r oota« B arni.LOG
    August 12th, 2007 03:10 2007年八月12日3点10分
    1

    [...] 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[ ...]

  2. Jon乔恩
    May 3rd, 2008 05:43 2008年5月3号05:43
    2

    ‘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米的报告仅主机和用户相关的标准输入终端

  3. Emilio埃米利
    November 1st, 2008 03:06 08年11月1号03:06
    3

    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.谢谢。

Leave a Reply留下一个回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签: href="" title="">的<a <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> “删除日期时间= “ ” “的<em> <i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅没有评论


Custom Search

New Articles新文章

Incoming Search Terms for the Article收到的搜索字词的文章

set root email address 设置根的电子邮件地址 - - set root email 设置根电子邮件 - - linux root mail Linux的根邮件 - - linux send email on login Linux系统发送电子邮件的登录 - - linux change root email Linux的改变根电子邮件 - - linux send email when user logs in Linux系统发送电子邮件时,用户登录 - - node/4 节点/ 4 - - all 全部 - - alert on root login 警惕root登录 - - Linux Mail change from Linux的邮件改变 - - mail login linux 邮件登录Linux操作系统 - - linux email alert Linux的电子邮件戒备 - - email alert on windows logon 电子邮件戒备在Windows登录 - - linux root email address Linux的根电子邮件地址 - - mail on root login 邮件root登录 - - linux mail change address Linux的电子邮件地址变更 - - send echo email login root 发送电子邮件登录回声根 - - email alert root login 电子邮件戒备root登录 - - linux mail login Linux的电子邮件登录 - - mail alert root access 邮件提醒根访问 - - linux send email login Linux系统发送电子邮件登录 - - email on root login 电子邮件root登录 - - ubuntu get alerts and alerts via email 获得Ubuntu的警示和警报通过电子邮件 - - change root email address 变化的根源电子邮件地址 - - mail when login linux 邮件时,登录的Linux - - root login linux root登录Linux操作系统 - - how to send a mail to root 如何发送邮件,以根 - - how to send mail to root linux 如何将邮件发送到Linux的根 - - email send logs linux 电子邮件发送日志Linux操作系统 - - freebsd send email od root login FreeBSD的发送电子邮件起始root登录 - - freebsd send alert when user login FreeBSD的发送警告当用户登录 - - how to server linux server login logs 如何服务器Linux服务器登录日志 - - linux email when root logs in Linux的电子邮件时,根原木 - - linux mail change email address Linux操作系统邮件的电子邮件地址变更 - - root email address 根电子邮件地址 - - send email when root login 发送电子邮件时, root登录 - - send mail notification to root 发送邮件通知,根 - - send email on root login 发送电子邮件的root登录 - - send root email to multiple users 根电子邮件发送给多个用户 - - @email.com Email directories @ email.com电子邮件目录 - - automatic email when user login on linux 自动回复邮件时,用户登录在Linux上 - - linux email you root Linux的电子邮件通知您根 - - linux send mail to root Linux系统发送邮件,以根 - - linux should root get mail? Linux的根应收取邮件? - - linux mail login Linux的电子邮件登录 - - root mail linux Linux的根邮件 - - send email to root 发送电子邮件至根 - - what is the Greek root of incident 什么是希根事件 - - alert mail linux 警惕电子邮件的Linux - - alert javascript display french language linux 警惕的javascript显示法语Linux操作系统 - -