{"id":4215,"date":"2012-11-21T13:21:19","date_gmt":"2012-11-21T05:21:19","guid":{"rendered":"http:\/\/jpuyy.com\/?p=4215"},"modified":"2013-01-06T16:01:46","modified_gmt":"2013-01-06T08:01:46","slug":"ssh-login-mail-alert","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=4215","title":{"rendered":"ssh\u767b\u5f55\u81ea\u52a8\u53d1\u90ae\u4ef6\u63d0\u9192"},"content":{"rendered":"<p>\u5927\u524d\u63d0\uff1a<\/p>\n<p>\u56e0\u6d89\u53ca\u5230\u53d1\u90ae\u4ef6\uff0cdebian\u4e0b\u9700\u5b89\u88c5exim4\u5e76\u53ef\u5bf9\u5916\u53d1\u90ae\u4ef6\uff0ccentos\u5219\u9700\u5b89\u88c5mailx,sendmail\u3002<\/p>\n<p>\u65b9\u68481\uff0c\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548\uff0c\u521b\u5efa\u6587\u4ef6<\/p>\n<pre>vim \/etc\/ssh\/sshrc<\/pre>\n<p>\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<pre>#!\/bin\/bash\r\nyourmail=2430645330@qq.com\r\nmail -s \"notification:user $USER login from ${SSH_CLIENT%% *}\" $yourmail &lt;&lt;EOT\r\n the ip information : http:\/\/www.123cha.com\/ip\/?q=${SSH_CLIENT%% *}\r\n login date: `date +%Y\/%m\/%d\" \"%H:%M:%S`\r\n if this is not you , please contact xxx for help.\r\nEOT<\/pre>\n<p>\u65b9\u68482\uff0c\u4e0d\u5f71\u54cd\u4ed6\u4eba\uff0c\u53ea\u9488\u5bf9\u81ea\u5df1\u7684\u8d26\u6237<\/p>\n<pre>vim ~\/.bashrc<\/pre>\n<p>\u6dfb\u52a0<\/p>\n<pre>echo 'ALERT Shell Access on:' `date` `who` | mail -s \"Alert: Root Access from `who | cut -d\"(\" -f2 | cut -d\")\" -f1`\" example@example.com<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u524d\u63d0\uff1a \u56e0\u6d89\u53ca\u5230\u53d1\u90ae\u4ef6\uff0cdebian\u4e0b\u9700\u5b89\u88c5exim4\u5e76\u53ef\u5bf9\u5916\u53d1\u90ae\u4ef6\uff0ccentos\u5219\u9700\u5b89\u88c5mailx,sendmail\u3002 \u65b9\u68481\uff0c\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548\uff0c\u521b\u5efa\u6587\u4ef6 vim \/etc\/ssh\/sshrc \u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9 #!\/bin\/bash yourmail=2430645330@qq.com mail -s &#8220;notification:user $USER login from ${SSH_CLIENT%% *}&#8221; $yourmail &lt;&lt;EOT the ip information : http:\/\/www.123cha.com\/ip\/?q=${SSH_CLIENT%% *} login date: `date +%Y\/%m\/%d&#8221; &#8220;%H:%M:%S` if this is not you , please contact xxx for help. EOT \u65b9\u68482\uff0c\u4e0d\u5f71\u54cd\u4ed6\u4eba\uff0c\u53ea\u9488\u5bf9\u81ea\u5df1\u7684\u8d26\u6237 vim ~\/.bashrc \u6dfb\u52a0 echo &#8216;ALERT Shell Access on:&#8217; `date` `who` | mail -s [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[117],"class_list":["post-4215","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ssh"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4215"}],"version-history":[{"count":13,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4215\/revisions"}],"predecessor-version":[{"id":4236,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4215\/revisions\/4236"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}