In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to achieve the script SSH login email alarm", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn how to achieve the script SSH login email alarm bar!
Login protection is a very important link, which will be explained in detail in the following way:
Two days ago @ cyy sent me a picture.
Then I thought of USHQ's ssh login app notification feature, and then it would be nice if I deployed this to a server for my own use. At least one more layer of safety.
First of all, I'd like to thank @ Legion for fixing a few mistakes and Geo2IP's JSON conversion. (P.S. This man is a great god of automation operation and maintenance, and now works in a data statistics enterprise in Germany.)
Of course, compared with him, I am a very poor fighter. Everyone must learn more from @ Legion.
Say what needs to be prepared:
Sendmail or Postfix
Php
Bash
CentOS/Debian/Ubuntu
If you do not have components such as php sendmail Postfix in your production environment, please move to:
@ Legion: Linux uses shell script to realize ssh login alarm
Reference file
The first is the alarm script file.
Shell
#! / bin/sh#### File Name: Login-alert.sh# Author: Jason# Email: master#deamwork.com# Created Time: Tue Jul 21 2015 21:23:16 PM CST # # require jq#wget http://stedolan.github.io/jq/download/linux64/jq-O / usr/local/bin/jq#chmod + x / usr/local/bin/jq#if error Please # following one#PATH=/usr/local/nginx/sbin:/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin#Geo2IP by Legion (http://www.dwhd.org/)eval `curl-s "http://ip.taobao.com/service/getIpInfo.php?ip=${SSH_CLIENT%% *}" | jq. | | awk-filler: | [] + | "'{if ($3 million / ^ (country | area | region | city | isp) $/) {print $3" = "$7}}'`# html mail contentcat > > mail-no-base64.html / dev/null 2 > & 1 mail.php EOFphp mail.phpyes y | rm mail-no-base64.html mail-base64.html mail.php |
Then there is how to trigger the script:
Shell
The code is as follows:
Echo "screen-fa-d-m-S WL / etc/Login-alert.sh" > > / etc/profile
In this way, a new terminal or a copy terminal will trigger an alarm.
If you are using smtp, please save the following file as smtp-class.php
PHP
Achieve results:
At this point, I believe that "how to achieve the script SSH login email alarm" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.