微信登录提示境外非法服务器,使用shell脚本监控用户登陆服务器并发送提示信息给微信...
1.需要在/etc/ssh/目錄下面創(chuàng)建一個名為sshrc的文件,執(zhí)行權限可給可不給,那么在有人通過ssh遠程登錄這臺服務器的時候,這段腳本就會被執(zhí)行
#!/bin/bash
###V1---###
CropID='xxxxxxxxxx'
Secret='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
#Gtoken=$(/usr/bin/curl $GURL -H "DNT: 1" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: zh-CN,zh;q=0.8" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 BIDUBrowser/8.1 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "X-DevTools-Emulate-Network-Conditions-Client-Id: B546FC80-414C-403F-95F0-EB0F70E58EF7" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" --compressed | awk -F \" '{print $4}')
Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F\" '{print $10}')
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
function body() {
local int appId=
#local userId=$
local userId="LinYouYi"
local partyId=
local msg='有用戶上線請注意:\n主機名:'`hostname`'\n主機ip:'`curl ifconfig.me`'\n登錄用戶:'`whoami`'\n登錄時間:'`date`
printf '{\n'
printf '\t"touser":"'"$userId"\"",\n"
printf '\t"toparty":"'"$partyId"\"",\n"
printf '\t"msgtype": "text",'"\n"
printf '\t"agentid":"'"$appId"\"",\n"
printf '\t"text":{\n'
printf '\t\t"content":"'"$msg"\"
printf '\n\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}
#/usr/bin/curl --data-ascii "$(body $1)" $PURL
/usr/bin/curl --data-ascii "$(body)" $PURL
shell腳本ssh自動登陸服務器
#!/bin/shsshpass -p "your password" ssh user@ip 注意: 需要先安裝sshpass: 源碼下載地址:http://sourceforg ...
shell腳本監(jiān)控Linux系統(tǒng)性能指標
2016-11-04 22:41 原作者不詳 分類: Linux(7) 在服務器運維過程中,經常需要對服務器的各種資源進行監(jiān)控, 例如:CPU的負載監(jiān)控,磁盤的使用率監(jiān)控,進程數目監(jiān)控等等,以在系統(tǒng)出 ...
Linux簡單Shell腳本監(jiān)控MySQL、Apache Web和磁盤空間
Linux簡單Shell腳本監(jiān)控MySQL.Apache Web和磁盤空間 1. 目的或任務 當MySQL數據庫.Apache Web服務器停止運行時,重新啟動運行,并發(fā)送郵件通知: 當服務器磁盤的空 ...
用shell腳本監(jiān)控進程是否存在 不存在則啟動的實例
用shell腳本監(jiān)控進程是否存在 不存在則啟動的實例,先上代碼干貨: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]th ...
linux shell腳本監(jiān)控進程是否存在
用shell腳本監(jiān)控進程是否存在 不存在則啟動的實例,先上代碼干貨:?? ?#!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ...
【轉】shell腳本實現多臺服務器自動巡檢--可參考學習
shell腳本實現多臺服務器自動巡檢 ? 摘要: ? ??????? 運維服務一個項目二十多臺(或者多臺)服務器,每天要做服務器的性能巡檢工作是查看服務器的CPU.內存.磁盤空間是否在正常值范圍內.像 ...
shell腳本批量ssh登陸主機并執(zhí)行命令
shell腳本批量ssh登陸主機并執(zhí)行命令 今天在客戶現場遇到了這個問題,客戶沒有管理工具,無法批量登陸主機下發(fā)命令,幾個個C段啊,讓我一個一個登陸,.................. 所以寫了個s ...
shell腳本監(jiān)控網站狀態(tài)
shell腳本監(jiān)控網站狀態(tài) #!/bin/sh date=`date +"%Y%m%d-%H%M"` title="status" contentFail=&q ...
shell腳本實現多臺服務器自動巡檢
shell腳本實現多臺服務器自動巡檢?摘要:???????? 運維服務一個項目二十多臺(或者多臺)服務器,每天要做服務器的性能巡檢工作是查看服務器的CPU.內存.磁盤空間是否在正常值范圍內.像這樣每天 ...
隨機推薦
過濾器Filter
實現Filter接口:
Alpha、Beta、RC、GA版本的區(qū)別 ZT
http://www.blogjava.net/RomulusW/archive/2008/05/04/197985.html Alpha:是內部測試版,一般不向外部發(fā)布,會有很多Bug.一般只有測試 ...
JAVA 數組實例-求學生成績的最大成績,獲取數組中的最大值、最小值
實例: import java.util.*; //求學生最大成績 public class Test{ public static void main(String[] args){ System. ...
Maven 的41種骨架
1: internal -> appfuse-basic-jsf (創(chuàng)建一個基于Hibernate,Spring和JSF的Web應用程序的原型) 2: internal -> appfus ...
Linux 系統(tǒng)編程
簡介和主要概念 Linux 系統(tǒng)編程最突出的特點是要求系統(tǒng)程序員對它們工作的的系統(tǒng)的硬件和操作系統(tǒng)有深入和全面的了解,當然它們還有庫和系統(tǒng)調用上的區(qū)別. 系統(tǒng)編程分為:驅動編程.用戶空間編程和網絡編程 ...
命令行解釋器(shell)
unix> ./hello hello world unix> ll 顯示當前目錄下文件信息. shell為命令行解釋器,第一個單詞可以是內置的外殼命令,也可以是一個可執(zhí)行文件名.
Nginx的500,502,504錯誤解決方法
Nginx的500,502,504錯誤解決方法 一.解決500錯誤: 1.500錯誤指的是服務器內部錯誤,也就是服務器遇到意外情況,而無法履行請求. 2.500錯誤一般有幾種情況: (1)web腳本錯 ...
asp.net中kindeditor配置
KindEditor< ...[Swift]LeetCode950. 按遞增順序顯示卡牌 | Reveal Cards In Increasing Order
In a deck of cards, every card has a unique integer.? You can order the deck in?any order you want. ...
項目中PO、PM的職責區(qū)分
PO是product owner,是一個role,負責與stakeholders打交道,提煉stakeholders的需求,按照需求的價值以及緊急程度安排優(yōu)先級.PO是一個角色,對product ba ...
總結
以上是生活随笔為你收集整理的微信登录提示境外非法服务器,使用shell脚本监控用户登陆服务器并发送提示信息给微信...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 关联删除_mysql 关联删
- 下一篇: P2562kitty猫基因