<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Windows归档 - Liao&#039;s blog</title>
	<atom:link href="https://www.laobaiblog.top/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.laobaiblog.top/tag/windows/</link>
	<description>路漫漫其修远兮，吾将上下而求索</description>
	<lastBuildDate>Tue, 17 Mar 2026 12:17:51 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.laobaiblog.top/wp-content/uploads/2022/01/cropped-tyuu-32x32.png</url>
	<title>Windows归档 - Liao&#039;s blog</title>
	<link>https://www.laobaiblog.top/tag/windows/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>🚀 Claude Code × VSCode：开发者的 AI 终端利器配置指南</title>
		<link>https://www.laobaiblog.top/2026/03/17/%f0%9f%9a%80-claude-code-x-vscode%ef%bc%9a%e5%bc%80%e5%8f%91%e8%80%85%e7%9a%84-ai-%e7%bb%88%e7%ab%af%e5%88%a9%e5%99%a8%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 17 Mar 2026 12:04:22 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[Anthropic]]></category>
		<category><![CDATA[claude code]]></category>
		<category><![CDATA[macos]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[npm]]></category>
		<category><![CDATA[vscode]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=602</guid>

					<description><![CDATA[<p>Claude Code × VSCode TL;DR：手把手带你从零安装 Claude Code，并 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2026/03/17/%f0%9f%9a%80-claude-code-x-vscode%ef%bc%9a%e5%bc%80%e5%8f%91%e8%80%85%e7%9a%84-ai-%e7%bb%88%e7%ab%af%e5%88%a9%e5%99%a8%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97/">🚀 Claude Code × VSCode：开发者的 AI 终端利器配置指南</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>Claude Code × VSCode</h1>
<blockquote><p>
  <strong>TL;DR</strong>：手把手带你从零安装 Claude Code，并在 VSCode 里解锁最强 AI 编程体验。
</p></blockquote>
<hr />
<h2>前言</h2>
<p><strong>Claude Code</strong> 是 Anthropic 推出的 CLI 工具，它不只是代码补全——它能读懂整个项目上下文、自主修改文件、执行命令、跑测试，像一个真正的结对编程伙伴坐在你的终端里。</p>
<p>配合 VSCode 扩展，你会得到一个无缝嵌入编辑器的 AI Agent。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2026/03/17/%f0%9f%9a%80-claude-code-x-vscode%ef%bc%9a%e5%bc%80%e5%8f%91%e8%80%85%e7%9a%84-ai-%e7%bb%88%e7%ab%af%e5%88%a9%e5%99%a8%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97/%e5%be%ae%e4%bf%a1%e5%9b%be%e7%89%87_20260317201323_45_3/"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/微信图片_20260317201323_45_3.jpg" alt="" /></a></p>
<hr />
<h2>环境准备</h2>
<h3>前置依赖</h3>
<table>
<thead>
<tr>
<th>工具</th>
<th>最低版本</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>Node.js</td>
<td><code>&gt;= 18.x</code></td>
<td>运行时环境</td>
</tr>
<tr>
<td>npm</td>
<td><code>&gt;= 9.x</code></td>
<td>随 Node.js 附带</td>
</tr>
<tr>
<td>VSCode</td>
<td><code>&gt;= 1.90</code></td>
<td>编辑器本体</td>
</tr>
</tbody>
</table>
<p>检查当前环境：</p>
<pre><code class="language-bash line-numbers">node -v
npm -v
</code></pre>
<hr />
<h2>安装 Claude Code</h2>
<h3>全局安装 CLI</h3>
<p>npm（通用，所有平台）：</p>
<pre><code class="language-bash line-numbers">npm install -g @anthropic-ai/claude-code
</code></pre>
<p>WinGet（Windows，我使用的）：</p>
<pre><code class="language-bash line-numbers">winget install Anthropic.ClaudeCode
</code></pre>
<p>Homebrew（macOS / Linux）：</p>
<pre><code class="language-bash line-numbers">brew install claude
</code></pre>
<p>macOS / Linux / WSL：</p>
<pre><code class="language-bash line-numbers">curl -fsSL https://claude.ai/install.sh | bash
</code></pre>
<p>Windows PowerShell：</p>
<pre><code class="language-powershell line-numbers">irm https://claude.ai/install.ps1 | iex
</code></pre>
<p>Windows CMD：</p>
<pre><code class="language-bash line-numbers">curl -fsSL https://claude.ai/install.cmd -o install.cmd &amp;&amp; install.cmd &amp;&amp; del install.cmd
</code></pre>
<p>安装完成后验证：</p>
<pre><code class="language-bash line-numbers">claude --version
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_04f8e275fb5034a031ebe0e29f40be21.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_04f8e275fb5034a031ebe0e29f40be21.jpg" alt="" /></a></p>
<hr />
<h2>🚨 国内用户必读：代理配置</h2>
<blockquote><p>
  <strong>问题根源</strong>：Anthropic 屏蔽了来自中国 IP 的 API 访问，影响所有环节——OAuth 登录、API 调用、CLI 和 VSCode 扩展。即使拥有付费的 Claude Max 订阅，从中国 IP 发出的请求一律返回 403。<strong>必须先配置代理，再启动 Claude Code。</strong>
</p></blockquote>
<p><a class="wp-editor-md-post-content-link" href="https://gist.github.com/docularxu/db0053008b9f41328f29d39ffcf7c2b2?permalink_comment_id=6005883">常见报错</a>：</p>
<pre><code class="line-numbers">OAuth error: Failed to fetch user roles: Request failed with status code 403
</code></pre>
<pre><code class="line-numbers">Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_BAD_REQUEST
Note: Claude Code might not be available in your country.
</code></pre>
<p>以 v2rayN 为例（设置里查看端口，默认本地代理端口 <code>10808</code>，clash默认端口改为<code>7890</code>），需将 <code>HTTPS_PROXY</code> 环境变量指向本地代理。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_95fd419c81c7226bf3a36406d56cda20.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_95fd419c81c7226bf3a36406d56cda20.jpg" alt="" /></a></p>
<h3>临时设置（仅当前窗口有效）</h3>
<p><strong>CMD：</strong></p>
<pre><code class="language-cmd line-numbers">set HTTPS_PROXY=http://127.0.0.1:10808
</code></pre>
<p><strong>PowerShell：</strong></p>
<pre><code class="language-powershell line-numbers">$env:HTTPS_PROXY = "http://127.0.0.1:10808"
</code></pre>
<p>设置后在<strong>同一窗口</strong>直接运行 <code>claude</code> 即可。</p>
<h3>永久设置（推荐，重启后仍有效）</h3>
<p><strong>方式一：图形界面（新手推荐）</strong></p>
<ol>
<li><code>Win + I</code> → 搜索「高级系统设置」→ 点击「环境变量」</li>
<li>在「用户变量」区域点击「新建」</li>
<li>变量名：<code>HTTPS_PROXY</code>，变量值：<code>http://127.0.0.1:10808</code></li>
<li>确定保存，重新打开命令行窗口生效</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bc687a080f0be69a91791c495e677b77.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bc687a080f0be69a91791c495e677b77.jpg" alt="" /></a></p>
<p><strong>方式二：命令行一键设置</strong></p>
<pre><code class="language-powershell line-numbers">[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://127.0.0.1:10808", [EnvironmentVariableTarget]::User)
</code></pre>
<p>执行后重新打开命令行窗口即可，无需重启电脑。</p>
<h3>验证是否生效</h3>
<pre><code class="language-cmd line-numbers">:: CMD
echo %HTTPS_PROXY%
</code></pre>
<pre><code class="language-powershell line-numbers"># PowerShell
echo $env:HTTPS_PROXY
</code></pre>
<p>输出 <code>http://127.0.0.1:10808</code> 即为设置成功，之后再启动 Claude Code。</p>
<hr />
<h2>启动 Claude Code</h2>
<p>进入你的项目目录，直接启动：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bdbdecc37df57fb8c89920f4e96421b8.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bdbdecc37df57fb8c89920f4e96421b8.jpg" alt="" /></a></p>
<pre><code class="language-bash line-numbers">cd your-project
claude
</code></pre>
<p>弹出以下提示，选择 1 即可继续：</p>
<pre><code class="line-numbers">Accessing workspace: C:\Users\...
Quick safety check: Is this a project you created or one you trust?
❯ 1. Yes, I trust this folder
  2. No, exit
Enter to confirm · Esc to cancel
</code></pre>
<blockquote><p>
  若遇到连接报错。
</p></blockquote>
<pre><code class="line-numbers">Unable to connect to Anthropic services  
Failed to connect to api.anthropic.com: ERR_BAD_REQUEST  
Please check your internet connection and network settings.  
Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries
</code></pre>
<p><strong>Windows下操作:</strong></p>
<p>按下键盘 Win + R 键，输入 cmd 后回车，打开命令行程序<br />
在命令行中运行以下命令后回车</p>
<pre><code class="language-bash line-numbers">powershell -Command "<span class="katex math inline">f='%USERPROFILE%\.claude.json';</span>j=Get-Content <span class="katex math inline">f|ConvertFrom-Json;</span>j|Add-Member -NotePropertyName 'hasCompletedOnboarding' -NotePropertyValue <span class="katex math inline">true -Force;</span>j|ConvertTo-Json|Set-Content $f"
</code></pre>
<p>重启你的Claude Cli</p>
<p>首次启动会有简短的引导流程，授权完成后即可使用。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_51a2e21b2bcccac52ea6d6ed8911fb34.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_51a2e21b2bcccac52ea6d6ed8911fb34.jpg" alt="" /></a></p>
<hr />
<h2>VSCode 扩展安装与配置</h2>
<h3>安装扩展</h3>
<p>打开 VSCode，按 <code>Ctrl+Shift+X</code> 打开扩展市场，搜索：</p>
<pre><code class="line-numbers">Claude Code
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bc9879addb1c7d8307862eda8f54d09f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2026/03/wp_editor_md_bc9879addb1c7d8307862eda8f54d09f.jpg" alt="" /></a></p>
<p>找到 <strong>Anthropic</strong> 官方发布的扩展，点击 Install。</p>
<p>或者直接通过命令行安装：</p>
<pre><code class="language-bash line-numbers">code --install-extension anthropic.claude-code
</code></pre>
<h3>扩展功能一览</h3>
<p>安装完成后，你将解锁以下能力：</p>
<ul>
<li><strong>内嵌聊天面板</strong> — 不离开编辑器，直接和 Claude 对话</li>
<li><strong>选中代码提问</strong> — 高亮代码后右键，发送给 Claude 分析</li>
<li><strong>差异视图</strong> — Claude 的修改建议以 diff 形式展示，一键接受或拒绝</li>
<li><strong>终端集成</strong> — Claude 可直接在 VSCode 内置终端执行命令</li>
</ul>
<hr />
<h2>核心用法速查</h2>
<h3>基础对话</h3>
<pre><code class="language-bash line-numbers"># 启动交互式会话
claude

# 单次提问（非交互模式）
claude -p "解释一下这个项目的架构"
</code></pre>
<h3>常用快捷指令</h3>
<p>在 Claude Code 会话中，输入 <code>/</code> 触发命令列表：</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>功能</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>/help</code></td>
<td>查看帮助</td>
</tr>
<tr>
<td><code>/clear</code></td>
<td>清空上下文</td>
</tr>
<tr>
<td><code>/compact</code></td>
<td>压缩对话历史，节省 token</td>
</tr>
<tr>
<td><code>/model</code></td>
<td>切换模型</td>
</tr>
<tr>
<td><code>/cost</code></td>
<td>查看本次会话消耗</td>
</tr>
<tr>
<td><code>/review-pr</code></td>
<td>PR 代码审查</td>
</tr>
<tr>
<td><code>/init</code></td>
<td>初始化项目，生成 <code>CLAUDE.md</code></td>
</tr>
</tbody>
</table>
<h3>让 Claude 读懂你的项目</h3>
<p>在项目根目录启动 Claude，进入交互式会话后执行：</p>
<pre><code class="line-numbers">/init
</code></pre>
<p>这会生成一个 <code>CLAUDE.md</code>，你可以在里面写：</p>
<ul>
<li>项目架构说明</li>
<li>技术栈约定</li>
<li>代码风格要求</li>
<li>不希望 Claude 修改的文件</li>
</ul>
<p>Claude 每次启动都会自动读取这个文件。</p>
<hr />
<h2>VSCode 进阶配置</h2>
<h3>settings.json 推荐配置</h3>
<p>打开 <code>Ctrl+Shift+P</code> → <code>Open User Settings (JSON)</code>，添加：</p>
<pre><code class="language-json line-numbers">{
  "terminal.integrated.defaultProfile.windows": "Git Bash"
}
</code></pre>
<blockquote><p>
  其他 Claude Code 相关选项可在 VSCode 设置页（<code>Ctrl+,</code>）搜索 <code>claude-code</code> 查看完整列表，按需开启。
</p></blockquote>
<h3>自定义键位绑定</h3>
<p>打开 <code>Ctrl+Shift+P</code> → <code>Open Keyboard Shortcuts (JSON)</code>：</p>
<pre><code class="language-json line-numbers">[
  {
    "key": "ctrl+shift+a",
    "command": "claude-code.openChat"
  },
  {
    "key": "ctrl+shift+r",
    "command": "claude-code.reviewSelection"
  }
]
</code></pre>
<hr />
<h2>权限模式说明</h2>
<p>Claude Code 在执行文件读写、命令时会请求权限，分三种模式：</p>
<table>
<thead>
<tr>
<th>模式</th>
<th>行为</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>默认</strong></td>
<td>每次操作都询问你</td>
</tr>
<tr>
<td><code>--dangerously-skip-permissions</code></td>
<td>全自动，不询问（仅限受信任环境）</td>
</tr>
<tr>
<td><code>--allowedTools</code></td>
<td>精确指定允许的工具范围，例如 <code>--allowedTools Bash,Edit</code></td>
</tr>
<tr>
<td><code>--print</code> / <code>-p</code></td>
<td>非交互模式，单次执行后退出，适合脚本集成</td>
</tr>
</tbody>
</table>
<hr />
<h2>Hooks 机制（进阶）</h2>
<p>Claude Code 支持配置 Hooks，在特定事件触发时执行自定义脚本。</p>
<p>编辑 <code>~/.claude/settings.json</code>：</p>
<pre><code class="language-json line-numbers">{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo '[HOOK] 即将执行 Bash 命令'"
          }
        ]
      }
    ]
  }
}
</code></pre>
<p>可以用来：审计命令执行、拦截危险操作、记录日志。</p>
<hr />
<h2>常见问题排查</h2>
<h3>Q：claude: command not found</h3>
<pre><code class="language-bash line-numbers"># 检查 npm 全局安装路径是否在 PATH 中
npm config get prefix
# 将 {prefix}/bin 加入 PATH
</code></pre>
<h3>Q：403 / 无法连接 Anthropic 服务（国内常见）</h3>
<p>先配置代理，参考上方「国内用户必读」章节。代理配置完成后，在<strong>同一终端窗口</strong>再次执行 <code>claude</code>。</p>
<h3>Q：VSCode 扩展无法连接</h3>
<p>代理环境变量必须在启动 VSCode 的终端中生效，或永久写入系统环境变量，VSCode 扩展才能继承代理设置。确认终端中 <code>claude</code> 命令可以正常执行后，重启 VSCode。</p>
<h2>小技巧 &amp; 最佳实践</h2>
<ul>
<li><strong>用 <code>CLAUDE.md</code> 约束行为</strong>：写明&#8221;不要修改 <code>config/</code> 目录下的文件&#8221;之类的规则，Claude 会遵守。</li>
<li><strong>善用 <code>/compact</code></strong>：长对话会消耗大量 token，及时压缩可以降低成本。</li>
<li><strong>选中代码再提问</strong>：在 VSCode 里高亮代码后打开 Claude 面板，上下文更精准。</li>
<li><strong>让 Claude 写测试</strong>：直接说&#8221;给这个函数写单元测试&#8221;，效果出奇得好。</li>
<li><strong>多模型切换</strong>：复杂推理用 Opus，日常编码用 Sonnet，速度与效果自由切换。</li>
</ul>
<hr />
<h2>总结</h2>
<pre><code class="line-numbers">安装 CLI → 装 VSCode 扩展 → 初始化 CLAUDE.md → 开始 vibe coding
</code></pre>
<p>Claude Code 最大的价值不是补全代码，而是<strong>理解项目、自主行动</strong>。把它当作一个真正的协作者，而不是一个更聪明的 Tab 键。</p>
<hr />
<p><em>本文基于 Claude Code 最新版本（2026年3月）编写，部分功能随版本更新可能有所变化。</em></p>
<p><a href="https://www.laobaiblog.top/2026/03/17/%f0%9f%9a%80-claude-code-x-vscode%ef%bc%9a%e5%bc%80%e5%8f%91%e8%80%85%e7%9a%84-ai-%e7%bb%88%e7%ab%af%e5%88%a9%e5%99%a8%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97/">🚀 Claude Code × VSCode：开发者的 AI 终端利器配置指南</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>按照等保测评标准实施操作系统加固的建议和参考</title>
		<link>https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 07 Feb 2023 03:16:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[安全加固]]></category>
		<category><![CDATA[等保测评]]></category>
		<category><![CDATA[身份验证]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=379</guid>

					<description><![CDATA[<p>等保测评在如今项目安全性及验收结项都是至关重要的步骤。 Windows 以服务器绝大多数为Windo &#8230;</p>
<p><a href="https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/">按照等保测评标准实施操作系统加固的建议和参考</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>等保测评在如今项目安全性及验收结项都是至关重要的步骤。</em></p>
<h1>Windows</h1>
<p>以服务器绝大多数为Windows Server 2012 版本参考为例</p>
<h3>一、身份鉴别</h3>
<h6>1. 口令复杂度和口令更改周期</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 账户策略 —> 密码策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1ed28802b101df004f62f79c3e924126.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1ed28802b101df004f62f79c3e924126.jpg" alt="" /></a></p>
<h6>2. 登录失败和空闲超时</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 账户策略 —> 账户锁定策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ede9b9361fd2c479b6cb859161604eae.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ede9b9361fd2c479b6cb859161604eae.jpg" alt="" /></a></p>
<p>控制面板 —> 外观 —> 显示 —> 更改屏幕保护程序</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c8404cd48ff9d0c49b3e9b6e5ba457e1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c8404cd48ff9d0c49b3e9b6e5ba457e1.jpg" alt="" /></a></p>
<h6>3. 加密远程管理</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —> 管理模板—> Windows组件 —> 远程桌面服务 —> 远程桌面会话主机 —> 安全</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6cbde13dcc34fb411556ac067959dd50.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6cbde13dcc34fb411556ac067959dd50.jpg" alt="" /></a></p>
<p><span id="more-379"></span></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d5826d138a9dc08d0484a22158d1f267.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d5826d138a9dc08d0484a22158d1f267.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_40e85c6152a236959311879bde4c62dc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_40e85c6152a236959311879bde4c62dc.jpg" alt="" /></a></p>
<h3>二、访问控制</h3>
<h6>1. 禁用匿名用户guest</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_47fc7286ade29876066d96b1efa87a63.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_47fc7286ade29876066d96b1efa87a63.jpg" alt="" /></a></p>
<h6>2. 修改默认密码</h6>
<p>计算机管理（本地）—> 本地用户和组 —> 用户 —> Administrator —> 右键  —> 设置密码</p>
<h6>3. 禁用其他无关用户，创建多个个人用户，避免多人共用一个账户</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c9dd25370f529c9d23a19dad41226cbb.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c9dd25370f529c9d23a19dad41226cbb.jpg" alt="" /></a></p>
<h6>4. 授予管理用户所需的最小权限，实现管理用户的权限分离</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8d1498306241ba3efd1a64ec6a1ea097.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8d1498306241ba3efd1a64ec6a1ea097.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ba8bc7dd69d020d41b210fc4005d668a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ba8bc7dd69d020d41b210fc4005d668a.jpg" alt="" /></a><br />
<!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1813ec53c31f622502166044f3dfaf7d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1813ec53c31f622502166044f3dfaf7d.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fea37aba9d4eaa000467ba872fecd3f2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fea37aba9d4eaa000467ba872fecd3f2.jpg" alt="" /></a></p>
<h3>三、安全审计</h3>
<h6>1. 开启安全审计</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 本地策略 —> 审核策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3e118ca1ed6bd00977e41262fb408241.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3e118ca1ed6bd00977e41262fb408241.jpg" alt="" /></a></p>
<h6>2.设置日志保存时间和存储空间</h6>
<p>计算机管理 —> 系统工具 —> 事件查看器 —> Windows日志 —> 应用程序、安全、系统 —> 右键 —> 属性（三个都需要设置）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e13a7c94149bec3194810bb474d79240.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e13a7c94149bec3194810bb474d79240.jpg" alt="" /></a></p>
<h3>四、入侵防范</h3>
<h6>1. 删除业务非必要的组件和应用程序</h6>
<p>控制面板 —> 所有控制面板项 —> 程序和功能</p>
<h6>2. 关闭不需要的系统服务、默认共享和高危端口</h6>
<p><strong>关闭系统服务器：</strong><br />
计算机管理 —> 服务和应用程序 —> 服务<br />
禁用非必要的系统服务（如 Print Spooler、Remote Registry Service等）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_af7bbaf19f8182e05507555d699e1d9f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_af7bbaf19f8182e05507555d699e1d9f.jpg" alt="" /></a></p>
<p><strong>关闭默认共享：</strong><br />
计算机管理 —> 系统工具 —> 共享文件夹 —> 右键 —> 停止共享<br />
关闭系统默认共享（如C、D、E）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_931ab2fe4f226c336d30817a2d86995f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_931ab2fe4f226c336d30817a2d86995f.jpg" alt="" /></a></p>
<p><strong>禁用高危端口一：</strong><br />
Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> IP安全策略，在 本地计算机<br />
禁用高危端口的策略（至少包括TCP135、139、445、UDP135、137、138、445端口）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b4f0d9641fbe01b78cb35588db3a890c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b4f0d9641fbe01b78cb35588db3a890c.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_37c1a6c91d6e0cd773cf3ae8c7e1bd3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_37c1a6c91d6e0cd773cf3ae8c7e1bd3a.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_0899a1920072f750f5440d1e43ced8a6.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_0899a1920072f750f5440d1e43ced8a6.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fff5f55a6293948110315e535b91fb9a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fff5f55a6293948110315e535b91fb9a.jpg" alt="" /></a></p>
<p><strong>禁用高危端口二：</strong><br />
控制面板 —> 系统和安全 —> 管理工具 —> 高级安全Windows防火墙 —> 入站规则<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e69e6f91287d196c95ac0e962d21e469.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e69e6f91287d196c95ac0e962d21e469.jpg" alt="" /></a></p>
<h6>3. 设置远程桌面地址限制</h6>
<p>控制面板—>管理工具—>高级安全Windows防火墙—>入站规则—>远程桌面-用户模式（TCP-In）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6422d12b92c3cbefba4cc1cf4e4db96b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6422d12b92c3cbefba4cc1cf4e4db96b.jpg" alt="" /></a></p>
<h6>五、恶意代码防范</h6>
<p>1、安装杀毒软件并更新病毒库（火绒安全仅为参考防病毒软件）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_23abb6ab2608f92093bdfbec87694254.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_23abb6ab2608f92093bdfbec87694254.jpg" alt="" /></a></p>
<h1>Linux</h1>
<p>说明：以下以CentOS Linux release 7.9.2009 (Core)  64位 为例，提供等保整改操作参考。</p>
<h3>一、身份鉴别</h3>
<h6>1. 口令复杂度和口令更改周期</h6>
<p><strong>口令更改周期：</strong><br />
<strong>方法一：</strong><br />
在/etc/login.defs中修改（修改原有的，并非添加）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e1c1537efdf8ec0a3c3a2daa3af605a8.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e1c1537efdf8ec0a3c3a2daa3af605a8.jpg" alt="" /></a><br />
（如经重启后无效或服务器不能重启，需逐一执行修改，参考方法二（无需重启））</p>
<p><strong>方法二（无需重启修改密码有效期）：</strong><br />
查看某个用户的密码设置情况：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_df5c68d5c04a607852280cf851235ef3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_df5c68d5c04a607852280cf851235ef3.jpg" alt="" /></a><br />
强制root用户下次登陆时修改密码（-d 0），并且设置密码最低有效期0（-m 1）和最高有限期90（-M 90），提前7天发警报提示-W 7 （root为用户名，可改成需要修改的用户）<br />
<code>chage -d 0 -m 1 -M 90 -W 7 root</code></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_06012c4fe40e5f7b44da7f634d0f193c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_06012c4fe40e5f7b44da7f634d0f193c.jpg" alt="" /></a></p>
<p><strong>口令复杂度配置：</strong><br />
在/etc/pam.d/system-auth中找到</p>
<pre><code class="language-shell line-numbers">password requisite pam_pwquality.so try_first_pass local_users_only
</code></pre>
<p>然后在其后面添加以下配置</p>
<pre><code class="language-shell line-numbers">retry=3 authtok_type= minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 enforce_for_root
</code></pre>
<p>配置后：</p>
<pre><code class="language-shell line-numbers">password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 enforce_for_root
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_390daa1840450e721c26899f33957b38.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_390daa1840450e721c26899f33957b38.jpg" alt="" /></a><br />
配置参数说明：<br />
retry=3 尝试三次<br />
minlen=8 密码最小长度为8个字符。<br />
lcredit=-1 密码应包含的小写字母的至少一个<br />
ucredit=-1 密码应包含的大写字母至少一个<br />
dcredit=-1 将密码包含的数字至少为一个<br />
ocredit=-1 设置其他符号的最小数量，例如@，＃、! $％等，至少要有一个<br />
enforce_for_root 确保即使是root用户设置密码，也应强制执行复杂性策略</p>
<h6>2. 登录失败和空闲超时</h6>
<p><strong>登录失败处理功能：（配置三个文件方可全方位生效）</strong><br />
在 <strong>/etc/pam.d/system-auth</strong> 文件加入以下配置 <strong>（请找到相应的对应区域，且必须按以下命令顺序）</strong><br />
在 <strong>/etc/pam.d/system-auth</strong> 下首行#%PAM-1.0下增加找到相应位置并添加：</p>
<pre><code class="language-shell line-numbers">auth  required  pam_tally2.so onerr=fail deny=5 unlock_time=300 even_deny_root  root_unlock_time=60
</code></pre>
<p><strong>onerr=fail</strong> 表示连续登录失败，<strong>deny=5</strong> 表示超过5次登录失败即锁定，<strong>unlock_time=300</strong>表示普通用户锁定300秒，<strong>even_deny_root</strong> 表示对root账户生效，<strong>root_unlock_time=60</strong>表示root用户锁定60秒。<br />
配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d7e7abfa412c6e626f53fbd13b225b7d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d7e7abfa412c6e626f53fbd13b225b7d.jpg" alt="" /></a></p>
<p>在 <strong>/etc/pam.d/sshd</strong> 和 <strong>/etc/pam.d/login</strong>中在首行#%PAM-1.0下增加：</p>
<pre><code class="language-shell line-numbers">auth  required  pam_tally2.so deny=5 unlock_time=300 even_deny_root root_unlock_time=60
</code></pre>
<p><strong>/etc/pam.d/sshd</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg" alt="" /></a></p>
<p><strong>/etc/pam.d/login</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg" alt="" /></a></p>
<p><strong>/etc/pam.d/login</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b1c623a18a58699f233fbfb91c2a6622.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b1c623a18a58699f233fbfb91c2a6622.jpg" alt="" /></a></p>
<p><strong>注意：</strong><br />
1）注意上面命令行写在文件的顺序，没配置正确有可能root都无法登录。<br />
2）如果想锁住root用户，在pam_tally2.so 条目里添加 even_deny_root 选项</p>
<p><strong>解锁方法：</strong><br />
查询密码错误情况：pam_tally2<br />
在root权限下：</p>
<pre><code class="language-shell line-numbers">pam_tally2  –user=root  --reset  #解锁某一个用户（root）
pam_tally2  --reset  #解锁所有用户
</code></pre>
<p>在普通用户权限下：</p>
<pre><code class="language-shell line-numbers">sudo  pam_tally2  –user=root  --reset  #解锁某一个用户（root）
sudo  pam_tally2  --reset  #解锁所有用户
</code></pre>
<p>空闲超时自动退出：<br />
在 /etc/profile末尾添加：</p>
<pre><code class="language-shell line-numbers">export TMOUT=600
</code></pre>
<p>说明：0代表永不自动退出，600代表600秒自动退出。<br />
执行命令source /etc/profile使配置生效</p>
<h6>3. 加密远程管理</h6>
<p>使用 <strong>netstat -ntpl | grep LISTEN</strong>查看是否有开启23端口（telnet服务）<br />
一般情况下，默认是使用ssh服务（22端口）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d337d079e02f3dbb3d2d73f562dd9478.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d337d079e02f3dbb3d2d73f562dd9478.jpg" alt="" /></a></p>
<h3>二、访问控制</h3>
<h6>1. 禁用多余用户（禁用所有非必要的用户）</h6>
<p>修改 <strong>/etc/passwd</strong>文件中用户登录的shell，添加<strong>nologin</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_53e5cfcdd3a08c713472aa34b8241007.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_53e5cfcdd3a08c713472aa34b8241007.jpg" alt="" /></a></p>
<h6>2. 创建多个个人用户，避免多人通用一个账户</h6>
<p>为每个用户创建一个独立的账户，避免用户都使用一个管理用户root</p>
<pre><code class="language-shell line-numbers">#创建新用户命令：
adduser user1 #添加一个名为user1的用户
#修改（添加）新用户密码：
Passwd user1
#输入两次密码即可
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_aa629bb1569e207fe4648878e9ee085f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_aa629bb1569e207fe4648878e9ee085f.jpg" alt="" /></a></p>
<h6>3. 修改默认口令</h6>
<p>修改默认口令，既修改默认账户root的默认口令，Centos 8在安装的时候创建root账户时，口令就不能为默认口令且要求具有复杂度要求，所以不存在默认口令。以下提供修改口令的命令供参考：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_f946045db052c3be8ecbec50d2871f3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_f946045db052c3be8ecbec50d2871f3a.jpg" alt="" /></a></p>
<h6>4. 授予管理用户所需的最小权限，实现管理用户的权限分离</h6>
<p>操作系统暂难实现三权分立，只需根据业务需求分配权限即可</p>
<h6>5. 关闭root账户直接远程登录</h6>
<p>在 <strong>/etc/ssh/sshd_config</strong>中修改“<strong>PermitRootLogin</strong>”参数为“no”<br />
<strong>注意：</strong> 修改前请确认具有普通用户，或创建一个可供远程管理的普通用户！！！</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5080388e88162b3abdf127c80e207c44.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5080388e88162b3abdf127c80e207c44.jpg" alt="" /></a></p>
<p>配置后，用户不能用root账户直接远程登录系统，需用普通账户远程登录，然后su切换到root账户<br />
随后<strong>重启ssh服务</strong>即可：</p>
<pre><code class="language-shell line-numbers">systemctl restart sshd.service
</code></pre>
<h6>6. 应对重要主体和客体设置安全标记，并控制主体对有安全标记信息资源的访问</h6>
<p>将 <strong>/etc/selinux/config</strong>中<strong>SELINUX</strong>参数默认为<strong>enforcing</strong>（强制模式）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e5637a2527ba98844e6e21f3a571c9e2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e5637a2527ba98844e6e21f3a571c9e2.jpg" alt="" /></a></p>
<h3>三、安全审计</h3>
<h6>1. 开启安全审计和审计保护进程</h6>
<p>查看auditd和rsyslogd进程的状态（默认是开启状态）：</p>
<pre><code class="language-shell line-numbers">service auditd status 或
systemctl status auditd.service
service rsyslog status 或
systemctl status rsyslog.service
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d7952e7813c0aef476915bff715caad.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d7952e7813c0aef476915bff715caad.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_67136bf145ef112fe46cd7b14a29ecc7.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_67136bf145ef112fe46cd7b14a29ecc7.jpg" alt="" /></a></p>
<p>如果没有开启auditd和rsyslog服务，使用以下命令开启（重启）：</p>
<pre><code class="language-shell line-numbers">service auditd restart 或
systemctl restart auditd.service
service rsyslog restart 或
systemctl restart rsyslog.service
</code></pre>
<p>设置auditd和rsyslog服务开机启动：</p>
<pre><code class="language-shell line-numbers">systemctl enable auditd
systemctl enable rsyslog
</code></pre>
<h6>2. 设置日志保存时间</h6>
<p>在 <strong>/etc/logrotate.conf</strong>文件修改<strong>rotate</strong>参数：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3a03f44337db2f4973c72b86226467cd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3a03f44337db2f4973c72b86226467cd.jpg" alt="" /></a></p>
<p>默认情况下，以周为单位，修改rotate参数为26，26周为26*7=182天，满足180天以上要求。</p>
<p>使用ll /var/log/ 命令查看实际日志是否满足要求：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_bf08c96ed2844079e0121a3b84cf88c1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_bf08c96ed2844079e0121a3b84cf88c1.jpg" alt="" /></a></p>
<p>日志时间满足180天，如需确认可查看以上文件进行确认。</p>
<h6>4. 设置审计记录备份（配置日志服务器）</h6>
<p><strong>注：</strong> 该项配置暂未有统一加固整改建议（需根据每个系统的部署情况而定）<br />
查看 <strong>/etc/rsyslog.conf</strong>文件是否配置日志服务器或日志审计<strong>设备IP</strong>：</p>
<h3>四、入侵防范</h3>
<h6>1. 删除业务非必要的组件和应用程序</h6>
<p>使用<strong>yum list installed</strong>命令查看已安装的软件</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1e6dd75ced6b9c35a4a261c2806c9234.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1e6dd75ced6b9c35a4a261c2806c9234.jpg" alt="" /></a></p>
<h6>2. 关闭不必要的系统服务和高危端口</h6>
<p><strong>方法一：</strong><br />
使用<strong>netstat -ntlp | grep LISTEN</strong>命令查看开放端口状态以及对应的服务：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7961d1e2b6cc2cf22a4dd778d5483acc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7961d1e2b6cc2cf22a4dd778d5483acc.jpg" alt="" /></a></p>
<p>上图可以看到系统打开了<strong>cupsd服务（打印服务）</strong>，属于不必要的系统服务，使用以下命令进行关闭（举例说明，其他不必要的系统服务请自行判断后进行关闭）</p>
<pre><code class="language-shell line-numbers">systemctl stop cups
#并设置重启不启用cups服务
systemctl disable cups
#查看cups服务状态，确保cups服务已成关闭
systemctl status cups
</code></pre>
<p><strong>方法二：</strong><br />
使用 <strong>Nmap工具</strong>进行端口扫描（自身扫描或通过管理终端扫描）：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b27d94d160de6a99e0555132dc901f3c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b27d94d160de6a99e0555132dc901f3c.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_65ce0eb06d788fa80051667c63cc1192.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_65ce0eb06d788fa80051667c63cc1192.jpg" alt="" /></a></p>
<h6>3. 设置远程管理接入地址限制（限制SSH登录地址）</h6>
<p>这里<strong>Centos7</strong>有两种方法配置地址限制</p>
<p>第一种：通过 <strong>/etc/hosts.allow</strong>和 <strong>hosts.deny</strong>配置地址限制。<br />
<strong>/etc/hosts.allow</strong>配置如下：（<strong>允许IP地址ssh</strong>）</p>
<pre><code class="language-shell line-numbers">sshd:192.168.110.129:allow          #允许单个IP地址ssh
sshd:192.168.110.1:allow       #允许一个28掩码网络段ssh
sshd:192.168.110.0/28:allow       #允许一个28掩码网络段ssh
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_467ba704da2909779a523dc7ec5edbd5.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_467ba704da2909779a523dc7ec5edbd5.jpg" alt="" /></a></p>
<p><strong>/etc/hosts.deny</strong>配置如下：(禁止所有IP地址ssh)</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_081e30d1680c568cacfce053e106d229.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_081e30d1680c568cacfce053e106d229.jpg" alt="" /></a></p>
<p>重启ssh服务</p>
<pre><code class="language-shell line-numbers">Systemctl restart sshd
</code></pre>
<p>以上就是 <strong>白名单机制，Linux</strong>的检查策略是先看 <strong>/etc/hosts.allow</strong>中是否允许，如果允许直接放行；如果没有，则再看 <strong>/etc/hosts.deny</strong>中是否禁止，如果禁止那么就禁止连入。</p>
<p>第二种：采用防火墙规则配置地址限制（Firewalld）<br />
查看Firewalld状态：</p>
<pre><code class="language-shell line-numbers">systemctl status firewalld.service
firewall-cmd --state
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ec8f86c1f0632553bd36ab73bfc8ca6b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ec8f86c1f0632553bd36ab73bfc8ca6b.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5867fdb2ed5c571f1728c5373dacece.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5867fdb2ed5c571f1728c5373dacece.jpg" alt="" /></a></p>
<p>防火墙 <strong>Firewall</strong>的状态是<strong>开启的</strong>，这样子在防火墙配置的策略才会<strong>有效</strong>，如果防火墙是关闭的，则配置的策略为无效。</p>
<p>在配置防火墙策略之前，得先了解一下配置的一个思路，就拿配置限制SSH登录地址举例。先有一个白名单机制的思维，白名单机制就是除允许名单外的所有名单都是被拒绝访问的，如果一个服务全开放，白名单则毫无意义。所以要限制SSH登录地址，先确认SSH是否为开放服务，先查看当前配置的防火墙规则：</p>
<pre><code class="language-shell line-numbers">firewall-cmd --list-all
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d0368dcac4bbfc5f91edda2a5938896.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d0368dcac4bbfc5f91edda2a5938896.jpg" alt="" /></a></p>
<p>可以看到这里的规则是开放了ssh服务的，意思就是全开放，所有的IP均可以通过ssh远程该系统。那么要做限制SSH登录地址，首先要先在规则上禁止掉ssh服务全开放。</p>
<pre><code class="language-shell line-numbers">firewall-cmd --permanent --remove-service=ssh    #禁止ssh服务
firewall-cmd --permanent --add-service=ssh       #开放ssh服务
</code></pre>
<p>配置完这命令后，使用查看当前配置的防火墙规则命令进行查询，ssh服务全开放依旧存在，那是因为配置了防火墙规则后，需要手动重载防火墙服务，因为后续还需配置，这里先不重载。接下来就是配置允许指定IP（段）访问制定本地端口（<strong>ssh服务，22端口</strong>）(永久生效再加上 <strong>&#8211;permanent</strong>)</p>
<pre><code class="language-shell line-numbers">firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.110.128/28" port protocol="tcp" port="22" accept'  #允许指定IP段访问制定本地端口

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.110.1" port protocol="tcp" port="22" accept'  #允许指定IP访问制定本地端口
</code></pre>
<p>配置完成后，<strong>重载防火墙</strong>（不同于重启防火墙）</p>
<pre><code class="language-shell line-numbers">firewall-cmd --reload      #重载防火墙
systemctl restart firewalld.service      #重启防火墙
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_916071081b29e6bccf5ecec20eb62231.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_916071081b29e6bccf5ecec20eb62231.jpg" alt="" /></a></p>
<p>以上防火墙（<strong>Firewall</strong>）规则就已经实现<strong>限制SSH登录地址</strong>限制，<strong>仅允许192.168.110.129/28网络段</strong>和<strong>192.168.110.1</strong>访问该系统的 <strong>ssh服务（22端口）</strong>。</p>
<h3>五、恶意代码防范</h3>
<h6>1. 安装杀毒软件并更新病毒库（ClamAV）或安装其他终端检测软件</h6>
<p>安装方法请根据具体的系统版本进行百度或联系相关安全设备管家进行沟通安装。<br />
<a class="wp-editor-md-post-content-link" href="https://www.jianshu.com/p/c9b5d87d8335">安装ClamAV参考</a>：https://www.jianshu.com/p/c9b5d87d8335</p>
<p><a href="https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/">按照等保测评标准实施操作系统加固的建议和参考</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
