{"id":71,"date":"2026-10-31T12:00:36","date_gmt":"2026-10-31T20:00:36","guid":{"rendered":"\/?p=71"},"modified":"2026-10-31T12:00:36","modified_gmt":"2026-10-31T20:00:36","slug":"post-mvvvibmg","status":"publish","type":"post","link":"https:\/\/www.woiov.cn\/?p=71","title":{"rendered":"\u628a Lynis \u585e\u8fdb\u63a7\u5236\u53f0\uff1a\u4e0b\u8f7d\u3001\u89e3\u538b\u3001\u9000\u51fa\u7801\u3001\u8f93\u51fa\u89e3\u6790\uff0c\u56db\u9053\u5173"},"content":{"rendered":"<p>Lynis \u672c\u8eab\u4e0d\u96be\u88c5\u3002\u96be\u7684\u662f\u628a\u5b83\u585e\u8fdb\u4e00\u4e2a\u7531 Node \u8fdb\u7a0b\u6258\u7ba1\u3001\u8981\u5bf9\u7740\u4e00\u5806 Linux \u53d1\u884c\u7248\u5e72\u6d3b\u7684\u63a7\u5236\u53f0\u91cc\u2014\u2014\u6bcf\u53f0\u673a\u5668\u73af\u5883\u90fd\u4e0d\u4e00\u6837\uff0c\u4f60\u4e0d\u80fd\u9760\u4eba\u624b <code>apt install lynis<\/code> \u89e3\u51b3\u95ee\u9898\uff0c\u4e5f\u4e0d\u80fd\u6307\u671b\u300c\u70b9\u4e00\u4e0b\u5c31\u597d\u300d\u8fd9\u6761\u8def\u6ca1\u6709\u5206\u53c9\u3002<\/p>\n<p>\u72f8\u82b1\u4e91\u7684\u5b89\u5168\u4e2d\u5fc3\u662f\u8fd9\u4e48\u957f\u51fa\u6765\u7684\u3002\u4e0b\u9762\u56db\u9053\u5173\uff0c\u6bcf\u4e00\u9053\u90fd\u662f\u88ab\u771f\u5b9e\u62a5\u9519\u603c\u51fa\u6765\u7684\u3002<\/p>\n<h3>\u7b2c\u4e00\u5173\uff1a\u4e0b\u8f7d\uff0c\u8fd4\u56de 200 \u4e0d\u4ee3\u8868\u4f60\u62ff\u5230\u4e86\u6587\u4ef6<\/h3>\n<p>GitHub \u76f4\u8fde\u5728\u56fd\u5185\u673a\u5668\u4e0a\u662f\u4e0d\u7a33\u5b9a\u7684\uff0c\u8fd9\u4e2a\u5927\u5bb6\u90fd\u77e5\u9053\u3002\u7b2c\u4e00\u7248\u4ee3\u7801\u5199\u4e86\u5355\u6e90\u4e0b\u8f7d\uff0c\u5931\u8d25\u7387\u9ad8\u5f97\u6ca1\u6cd5\u770b\u3002\u540e\u6765\u6539\u6210\u4e09\u6e90\u515c\u5e95\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst sources = [\n  { name: 'GitHub \u76f4\u8fde', url: raw },\n  { name: 'ghfast.top \u955c\u50cf', url: 'https:\/\/ghfast.top\/' + raw },\n  { name: 'gh-proxy \u955c\u50cf', url: 'https:\/\/gh-proxy.com\/' + raw },\n]\n<\/code><\/pre>\n<p>\u987a\u5e8f\u4e0d\u80fd\u53cd\u3002\u955c\u50cf\u5076\u5c14\u4f1a\u628a\u9519\u8bef\u9875\u5f53\u6210 200 \u8fd4\u56de\uff0c<code>curl -f<\/code> \u8fd9\u65f6\u5019\u662f\u4e0d\u62a5\u9519\u7684\u2014\u2014\u5b83\u53ea\u770b HTTP \u72b6\u6001\u7801\u3002\u6240\u4ee5\u4e0b\u8f7d\u5b8c\u5fc5\u987b\u9a8c\u4e00\u4e0b\u5c3a\u5bf8\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst sz = fs.statSync(tmp).size\nif (sz &lt; 50000) return resolve({ ok: false, error: `\u6587\u4ef6\u8fc7\u5c0f\uff08${sz}B\uff09` })\n<\/code><\/pre>\n<p>50KB \u662f\u62cd\u51fa\u6765\u7684\u7ecf\u9a8c\u503c\u3002Lynis \u7684 master.tar.gz \u5728\u4e24\u4e09\u767e KB \u91cf\u7ea7\uff0c\u4e00\u5f20 HTML \u9519\u8bef\u9875\u9876\u591a\u51e0 KB\u3002\u8fd9\u4e2a\u9608\u503c\u6bd4\u4efb\u4f55\u72b6\u6001\u7801\u90fd\u8001\u5b9e\u3002<\/p>\n<h3>\u7b2c\u4e8c\u5173\uff1a\u4e0a\u4e00\u6b21\u5931\u8d25\uff0c\u4f1a\u6bd2\u6b7b\u4e0b\u4e00\u6b21<\/h3>\n<p>Lynis \u662f\u4ee5\u76ee\u5f55\u5f62\u5f0f\u5b58\u5728\u7684\uff0c\u4e0d\u662f\u5355\u4e2a\u4e8c\u8fdb\u5236\u3002\u5b89\u88c5\u6d41\u7a0b\u662f\u300c\u4e0b\u8f7d \u2192 \u89e3\u538b \u2192 \u5f52\u6574\u5230 <code>data\/security\/lynis<\/code>\u300d\u3002\u7b2c\u4e00\u7248\u7528\u7684\u662f <code>tar --one-top-level<\/code> \u76f4\u63a5\u89e3\u5230\u76ee\u6807\u76ee\u5f55\uff0c\u5e72\u51c0\u5229\u843d\u2014\u2014\u76f4\u5230\u6709\u4e00\u6b21\u7f51\u7edc\u65ad\u5728\u89e3\u538b\u4e2d\u95f4\uff0c\u7559\u4e0b\u534a\u4e2a\u76ee\u5f55\u3002<\/p>\n<p>\u4e0b\u4e00\u6b21\u70b9\u5b89\u88c5\uff0c<code>tar<\/code> \u76f4\u63a5\u7529\u4e00\u53e5 <code>File exists<\/code>\u3002\u7528\u6237\u770b\u5230\u7684\u662f\u300c\u5b89\u88c5\u5931\u8d25\u300d\uff0c\u5b9e\u9645\u4e0a\u662f\u300c\u4e0a\u6b21\u5931\u8d25\u7684\u5c38\u4f53\u8fd8\u5728\u8fd9\u300d\u3002<\/p>\n<p>\u6240\u4ee5\u5b89\u88c5\u51fd\u6570\u7b2c\u4e00\u884c\u4e0d\u662f\u4e0b\u8f7d\uff0c\u662f\u6e05\u5c38\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\ntry { fs.rmSync(target, { recursive: true, force: true }) } catch (e) {}\n<\/code><\/pre>\n<p>\u540c\u7406\uff0c\u626b\u63cf\u76ee\u5f55 <code>_stage<\/code> \u6bcf\u6b21\u4e5f\u8981\u5148\u5220\u3002\u8fd9\u4e00\u6b65\u770b\u7740\u810f\uff0c\u4f46\u5b83\u628a\u300c\u53ef\u91cd\u5165\u300d\u8fd9\u4ef6\u4e8b\u89e3\u51b3\u4e86\u3002\u4efb\u4f55\u4e00\u4e2a\u5b89\u88c5\u52a8\u4f5c\uff0c\u53ea\u8981\u5b83\u5199\u78c1\u76d8\uff0c\u5c31\u5e94\u8be5\u5148\u5047\u8bbe\u78c1\u76d8\u4e0a\u6709\u5783\u573e\u3002<\/p>\n<h3>\u7b2c\u4e09\u5173\uff1a\u89e3\u538b\u51fa\u6765\u7684\u76ee\u5f55\u53eb\u4ec0\u4e48\uff0c\u6ca1\u4eba\u4fdd\u8bc1<\/h3>\n<p><code>master.tar.gz<\/code> \u89e3\u5f00\u4ee5\u540e\u9876\u5c42\u76ee\u5f55\u662f <code>lynis-master<\/code>\u3002\u8fd9\u662f\u5e38\u6001\uff0c\u4f46\u4e0d\u662f\u627f\u8bfa\u3002\u6539\u4e86\u5206\u652f\u540d\u3001\u6362\u4e86\u6253\u5305\u65b9\u5f0f\u3001\u955c\u50cf\u91cd\u65b0\u6253\u4e86\u4e00\u6b21\u5305\uff0c\u90fd\u53ef\u80fd\u53d8\u6210\u5e73\u94fa\uff0c\u6216\u8005\u591a\u5957\u4e00\u5c42\u3002<\/p>\n<p>\u6240\u4ee5\u89e3\u538b\u4e0d\u80fd\u76f4\u63a5\u843d\u5230\u76ee\u6807\u4f4d\u7f6e\uff0c\u8981\u5148\u843d\u5230 <code>_stage<\/code>\uff0c\u7136\u540e\u53bb\u63a2\u6d4b\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst dirs = entries.filter((e) =&gt; e.isDirectory()).map((e) =&gt; e.name)\nif (dirs.length === 1) topDir = path.join(stageDir, dirs[0])\nelse if (dirs.length &gt; 1) {\n  const hit = dirs.find((d) =&gt; fs.existsSync(path.join(stageDir, d, 'lynis')))\n  topDir = hit ? path.join(stageDir, hit) : path.join(stageDir, dirs[0])\n} else topDir = stageDir   \/\/ \u76f4\u63a5\u5e73\u94fa\n<\/code><\/pre>\n<p>\u5224\u65ad\u4f9d\u636e\u662f\u300c\u54ea\u4e2a\u76ee\u5f55\u91cc\u771f\u7684\u8eba\u7740 <code>lynis<\/code> \u8fd9\u4e2a\u53ef\u6267\u884c\u811a\u672c\u300d\uff0c\u4e0d\u662f\u76ee\u5f55\u540d\u3002\u540d\u5b57\u4f1a\u53d8\uff0c\u6587\u4ef6\u4e0d\u4f1a\u3002<\/p>\n<p>\u63a2\u6d4b\u5b8c\u518d\u9012\u5f52\u590d\u5236\u5230\u76ee\u6807\u4f4d\u7f6e\uff0c\u4e2d\u95f4\u5c42\u4e22\u6389\u3002\u8fd9\u6837\u65e0\u8bba\u4e0a\u6e38\u600e\u4e48\u6253\u5305\uff0c\u843d\u5730\u7684\u7ed3\u6784\u90fd\u662f\u56fa\u5b9a\u7684\u2014\u2014\u8fd9\u662f\u7ed9\u672a\u6765\u7684\u81ea\u5df1\u7701\u4e8b\u3002<\/p>\n<h3>\u7b2c\u56db\u5173\uff1a\u9000\u51fa\u7801\u9a97\u4eba\uff0c\u8f93\u51fa\u683c\u5f0f\u4e5f\u9a97\u4eba<\/h3>\n<p>Lynis \u626b\u51fa\u95ee\u9898\u65f6\uff0c\u9000\u51fa\u7801\u4e0d\u662f 0\u3002\u8fd9\u610f\u5473\u7740\u4f60\u4e0d\u80fd\u7528 <code>if (err) return fail(...)<\/code> \u5224\u65ad\u626b\u63cf\u5931\u8d25\uff0c\u5426\u5219\u6bcf\u53f0\u6709\u8b66\u544a\u7684\u673a\u5668\u90fd\u662f\u300c\u626b\u63cf\u5931\u8d25\u300d\u3002<\/p>\n<p>\u5224\u636e\u5f97\u6362\u6210\u8f93\u51fa\u5185\u5bb9\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst run = await new Promise((resolve) =&gt; {\n  execFile(bin, ['audit', 'system', '--quick', '--no-colors'], {\n    cwd: LYNIS_DIR(),          \/\/ \u4e0d\u8bbe\u8fd9\u4e2a\uff0c\u5b83\u8bfb\u4e0d\u5230 include\/ \u4e0b\u7684\u5e93\n    timeout: 180000,\n    maxBuffer: 8 * 1024 * 1024, \/\/ \u9ed8\u8ba4 1MB\uff0c\u62a5\u544a\u4f1a\u88ab\u8170\u65a9\n    env: { ...process.env, TERM: 'dumb' },\n  }, (err, stdout, stderr) =&gt; {\n    resolve({ ok: !err || \/hardening index\/i.test(stdout || ''), out: (stdout || '') + (stderr || '') })\n  })\n})\n<\/code><\/pre>\n<p>\u4e09\u4e2a\u53c2\u6570\uff0c\u6bcf\u4e2a\u90fd\u662f\u5751\uff1a<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>\u53c2\u6570<\/th>\n<th>\u5c11\u4e86\u4f1a\u600e\u6837<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>cwd: LYNIS_DIR()<\/code><\/td>\n<td>\u627e\u4e0d\u5230 <code>include\/<\/code> \u91cc\u7684\u51fd\u6570\u5e93\uff0c\u76f4\u63a5\u62a5\u9519\u9000\u51fa<\/td>\n<\/tr>\n<tr>\n<td><code>maxBuffer: 8MB<\/code><\/td>\n<td>\u5b8c\u6574\u62a5\u544a\u88ab\u622a\u65ad\u5728 1MB\uff0c\u53ea\u5269\u524d\u534a\u622a\u6d4b\u8bd5\u9879<\/td>\n<\/tr>\n<tr>\n<td><code>env.TERM='dumb'<\/code><\/td>\n<td>\u90e8\u5206\u73af\u5883\u8d70\u4ea4\u4e92\u5206\u652f\uff0c\u8fdb\u7a0b\u6302\u4f4f\u76f4\u5230\u8d85\u65f6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u7136\u540e\u662f\u89e3\u6790\u3002Lynis \u8f93\u51fa\u5e26 ANSI \u8272\u7801\uff0c\u6b63\u5219\u76f4\u63a5\u5339\u914d\u4f1a\u5168\u5931\u6548\uff0c\u5fc5\u987b\u5148\u5265\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\nconst s = L.replace(\/\\x1b\\[[0-9;]*m\/g, '').trim()\nif ((m = s.match(\/Hardening index\\s*:\\s*(\\d+)\/))) out.hardening = Number(m[1])\nif ((m = s.match(\/^\\s*\\*\\s*(.+?)\\s*\\[([A-Z0-9\\-]+)\\]\/)) &amp;&amp; \/^(WARN|SUGG|FIND)\/.test(m[2])) {\n  \/\/ ...\n}\n<\/code><\/pre>\n<p>\u52a0\u56fa\u6307\u6570\u662f\u552f\u4e00\u4e00\u4e2a\u80fd\u8ba9\u4eba\u4e00\u773c\u770b\u61c2\u7684\u5206\u6570\uff0c\u6240\u4ee5\u5b83\u662f\u8fd9\u4e2a\u9875\u9762\u7684\u4e3b\u89d2\u3002\u5176\u4f59\u7684\u5efa\u8bae\u9879\u6309 <code>[SSH-7408]<\/code> \u8fd9\u79cd tag \u524d\u7f00\u5206\u5230 WARN \/ SUGG \u4e24\u4e2a\u6876\u91cc\uff0c\u524d\u7aef\u4e00\u6b21\u6700\u591a\u7ed9 40 \u6761\u2014\u2014\u591a\u7684\u6ca1\u4eba\u770b\u3002<\/p>\n<h3>\u5206\u6570\u53ea\u662f\u4e00\u4e2a\u5165\u53e3<\/h3>\n<p>\u771f\u6b63\u6709\u4ef7\u503c\u7684\u662f\u5206\u6570\u80cc\u540e\u7684\u52a8\u4f5c\u3002\u63a7\u5236\u53f0\u91cc\u9884\u7f6e\u4e86\u4e00\u952e\u5b89\u88c5\u7684\u5b89\u5168\u5de5\u5177\u96c6\uff08<code>fail2ban<\/code> \/ <code>ufw<\/code> \/ <code>rkhunter<\/code>\uff09\uff0c\u5269\u4e0b\u7684\u9760\u62a5\u544a\u9010\u6761\u63a8\u7740\u8d70\u3002\u7ecf\u9a8c\u4e0a\uff0c\u4e00\u53f0\u521a\u88c5\u597d\u7684 Ubuntu LTS \u5bb9\u5668\uff0c\u628a\u4e0b\u9762\u8fd9\u51e0\u4ef6\u4e8b\u505a\u5b8c\uff0c\u52a0\u56fa\u6307\u6570\u4f1a\u660e\u663e\u5f80\u4e0a\u8d70\uff1a<\/p>\n<ul>\n<li>SSH \u5173\u6389\u5bc6\u7801\u767b\u5f55\uff0c\u53ea\u7559\u5bc6\u94a5\uff0c<code>PermitRootLogin no<\/code><\/li>\n<li>\u88c5 <code>ufw<\/code>\uff0c\u9ed8\u8ba4 deny\uff0c\u53ea\u653e\u4e1a\u52a1\u7aef\u53e3<\/li>\n<li><code>fail2ban<\/code> \u76ef sshd\uff0c\u8fde\u9519\u4e94\u6b21\u5c01\u4e00\u5c0f\u65f6<\/li>\n<li>\u5f00 unattended-upgrades\uff0c\u5b89\u5168\u8865\u4e01\u522b\u7b49\u4eba<\/li>\n<li>\u5b9a\u671f <code>rkhunter --check<\/code>\uff0c\u88ab\u6362\u8fc7\u7684\u4e8c\u8fdb\u5236\u5b83\u4f1a\u558a<\/li>\n<li>\u5173\u6389\u4e0d\u7528\u7684\u670d\u52a1\uff0c<code>ss -lntu<\/code> \u91cc\u6bcf\u4e00\u6761\u90fd\u8981\u80fd\u89e3\u91ca<\/li>\n<li>\u65e5\u5fd7\u7559\u5b58\uff0c\u51fa\u4e86\u4e8b\u624d\u6709\u5f97\u67e5<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u90fd\u4e0d\u662f\u65b0\u6280\u672f\uff0c\u53ea\u662f\u6ca1\u4eba\u613f\u610f\u505a\u3002\u5de5\u5177\u7684\u4ef7\u503c\u4e0d\u5728\u4e8e\u544a\u8bc9\u4f60\u54ea\u91cc\u4e0d\u5bf9\uff0c\u5728\u4e8e\u628a\u300c\u54ea\u91cc\u4e0d\u5bf9\u300d\u53d8\u6210\u4e00\u5f20\u80fd\u5212\u6389\u7684\u6e05\u5355\u3002<\/p>\n<p>\u987a\u4fbf\u4e00\u53e5\uff1a\u62a5\u544a\u843d\u5728 <code>data\/security\/last-report.json<\/code>\uff0c\u76ee\u5f55\u6743\u9650\u7279\u610f\u8bbe\u6210 <code>755<\/code>\u2014\u2014\u5bbf\u4e3b\u673a\u4e0a\u7684\u5907\u4efd\u8fdb\u7a0b\u662f\u4ee5\u53e6\u4e00\u4e2a\u7528\u6237\u8dd1\u7684\uff0c\u6743\u9650\u8bbe\u6210 700 \u5b83\u8bfb\u4e0d\u5230\uff0c\u5907\u4efd\u91cc\u5c31\u6c38\u8fdc\u7f3a\u8fd9\u4e00\u5757\u3002<\/p>\n<p>\u8fd9\u79cd\u7ec6\u8282\u6ca1\u6709\u4efb\u4f55\u4e00\u5904\u4f1a\u62a5\u9519\uff0c\u53ea\u4f1a\u5728\u4f60\u9700\u8981\u5b83\u7684\u65f6\u5019\u7f3a\u5e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lynis \u672c\u8eab\u4e0d\u96be\u88c5\u3002\u96be\u7684\u662f\u628a\u5b83\u585e\u8fdb\u4e00\u4e2a\u7531 Node \u8fdb\u7a0b\u6258\u7ba1\u3001\u8981\u5bf9\u7740\u4e00\u5806 Linux \u53d1\u884c\u7248\u5e72\u6d3b\u7684\u63a7\u5236\u53f0\u91cc\u2014\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-cat-e68a80e69cafe697"],"_links":{"self":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.woiov.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}