How to Get Linux Server Sends Email Alert on Root Login如何讓Linux服務器發送電子郵件警報對根登錄
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服務器,這暴露了以互聯網和世界各地盡可能多的黑客,最好的,使服務器自動發送通知郵件到預定義的電子郵件地址,每次有人記錄在以root的身份向東道國。 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使用,以root的身份識別碼。
- 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編輯或使用微微六鍵入下列命令之一,在命令外殼行:
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.com迴聲'快訊-根殼准入對: ' `日期` `誰` |郵件- S的“警報:根訪問`誰|割喉式D ”類( “ - F 2進入|割喉式D ”類) “ - F 1的` ”用戶@ 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.現在註銷,並再次登錄,以root的身份,你應該收到一封電子郵件,提醒在您的收件箱。 The security trick should works on most popular flavor of Linux such as RedHat, CentOS, Ubuntu, FreeBSD and etc.安全理事會的伎倆,應該對工程最熱門的風味的Linux如RedHat作業, 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服務器
- Disable and Turn Off Telnet in Linux禁用和關閉的Telnet在Linux
- Change and Reset MySQL root Password改變和重置MySQL的root密碼
- Change User Name on Linux改變使用者名稱在Linux上
- Cannot FTP to Web Host or Server running cPanel/WHM不能FTP發布到Web主機或服務器運行的cPanel /的WHM
- cPanel Invalid License File After Changing Hostname Error的cPanel無效的許可文件後,改變主機的錯誤
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3安裝Web服務器在FreeBSD的6.0與2.2的Apache , MySQL 5.0的和PHP 5 -第3部分
- Check and Optimize MySQL Database Automatically with Crontab/Cron檢查和優化MySQL數據庫自動與crontab /玉米
- Restore Full Backup or cpmove File in cPanel Web Host恢復完整備份或cpmove文件中的cPanel Web主機
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4安裝Web服務器在Windows XP的Apache2 , php5和mysql4 -第4部分

































August 12th, 2007 03:10 2007年8月12日3時10分
[...] Linux - wysyłanie maila o logowaniu na konto roota Bardzo użyteczny skrypcik [...] [ … … ] Linux的-w ysyłaniem ailao l ogowaniu娜的帳戶r ootab ardzou żytecznys krypcik[ … … ]
May 3rd, 2008 05:43 2008年5月3日5時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 -米的報告,只有主機和用戶的相關標準輸入終端