Audit Log Login

Source: Internet
Author: User

Background: The company's audit logs often appear without logging commands, but can not monitor whether the audit function is normal. So our idea is to ssh into each host from the CMDB server every day. If the audit function is normal, you must have a logged-in record in the Auditlog.info file. If there is no change in this file within 24 hours, it indicates that the audit function of the host is abnormal and the log cannot be logged.


Create a logon script

#!/usr/bin/env python2.7import commands,requests,json#host_ip = ' 10.47.102.185 ' url = ' http://10.47.102.185/api/ecs ' r    = Requests.get (URL) ecss = Json.loads (r.text) for I in ecss:host_ip = i.get (' IP ') # if host_ip! = ' 10.174.107.151 ': Status,result = Commands.getstatusoutput (' ssh-o connecttimeout=3-o stricthostkeychecking=no [email protected]{0} '        echo \ "Audit Check\" "". Format (HOST_IP)) if status = = 0:print ' {0} Check Success '. Format (HOST_IP) Else: print ' {0} check failed '. Format (HOST_IP)

Connecttimeout=3 indicates a time-out of 3 seconds


Stricthostkeychecking

The first SSH login prompts to confirm yes/no, confirm Yes will add the remote node to the local ~/.ssh/known_hosts, the next time you connect the same node is no longer prompt. For the convenience of not confirm, you can use the following parameters login

ssh-o stricthostkeychecking=no ...

This will no longer confirm and automatically add information from the remote host to the ~/.ssh/known_hosts.


To create a daily scheduled task:

1 * * * root/usr/bin/python2.7/srv/script/audit_check.py

Trigger:

{Template OS linux:vfs.file.cksum[/var/log/userlog.info].diff (0)}=0



Audit Log Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.