8
n8n 中文网amn8n.com

带Slack的自动化文件完整性检查

中级

这是一个SecOps领域的自动化工作流,包含 8 个节点。主要使用 If, Ssh, Code, Cron, Slack 等节点。 使用SSH监控远程服务器文件完整性并发送Slack警报

前置要求
  • Slack Bot Token 或 Webhook URL
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Y4SJP07CnkFr6gvM",
  "meta": {
    "instanceId": "a287613f1596da776459594685fbf4e2b4a12124f80ab8c8772f5e37bff103ae",
    "templateCredsSetupCompleted": true
  },
  "name": "带 Slack 的自动化文件完整性检查",
  "tags": [],
  "nodes": [
    {
      "id": "a56ca493-a82b-45db-bc81-90c9d9368646",
      "name": "定时检查",
      "type": "n8n-nodes-base.cron",
      "position": [
        -416,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "334491fa-dfe6-4502-b704-1f852639b2cc",
      "name": "列出文件和校验和",
      "type": "n8n-nodes-base.code",
      "position": [
        -192,
        352
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 1
    },
    {
      "id": "a8f2ce95-e2af-45d7-a068-870f04d09f66",
      "name": "获取远程文件校验和",
      "type": "n8n-nodes-base.ssh",
      "position": [
        32,
        352
      ],
      "parameters": {
        "command": "sha256sum {{ $json.path }}"
      },
      "typeVersion": 1
    },
    {
      "id": "e2feef20-0895-4d3c-9dac-053766f4a298",
      "name": "校验和是否匹配?",
      "type": "n8n-nodes-base.if",
      "position": [
        256,
        352
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "28ac7db9-54aa-45c7-a711-df5c21e2f73f",
      "name": "结束工作流",
      "type": "n8n-nodes-base.noOp",
      "position": [
        480,
        448
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "71ef0e9f-4a7f-4c09-9511-4775df30a1cd",
      "name": "发送警报",
      "type": "n8n-nodes-base.slack",
      "position": [
        480,
        256
      ],
      "webhookId": "9feeeb83-df74-4011-89ef-3f63e069a6c3",
      "parameters": {
        "text": "=🚨 *File Integrity Alert!* 🚨\\nFile: *{{ $json.path }}* has been modified!\\nKnown Checksum: *{{ $json.knownChecksum }}*\\nCurrent Checksum: *{{ $json.stdout.split(' ')[0] }}*",
        "user": {
          "__rl": true,
          "mode": "id",
          "value": "[YOUR_SECURITY_ALERT_CHANNEL_ID]"
        },
        "select": "user",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "AFKF0YsguyhsagR0",
          "name": "temp"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "47a05b08-78a3-4bfa-8a98-bff0c883b5e8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        208
      ],
      "parameters": {
        "width": 1152,
        "height": 368,
        "content": "## 流程"
      },
      "typeVersion": 1
    },
    {
      "id": "ac402d8d-8588-4b51-a1dd-e7ea24ded695",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        608
      ],
      "parameters": {
        "color": 5,
        "width": 1152,
        "height": 352,
        "content": "# 🚨 自动化文件完整性检查 🛡️"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4489311f-ff4b-4df7-8ac6-f378f84c5361",
  "connections": {
    "Scheduled Check": {
      "main": [
        [
          {
            "node": "List Files & Checksums",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checksums Match?": {
      "main": [
        [
          {
            "node": "Send Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "End Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Files & Checksums": {
      "main": [
        [
          {
            "node": "Get Remote File Checksum",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Remote File Checksum": {
      "main": [
        [
          {
            "node": "Checksums Match?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 安全运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量8
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Marth

Marth

@marth

Simplifying Business with Smart Automation. I create and share user-friendly, highly efficient n8n workflow templates for SMEs, focusing on digital marketing, sales, and operational excellence. Get ready to automate, innovate, and elevate your business. Connect me on Linkedin for custom solutions.

外部链接
在 n8n.io 查看

分享此工作流