<?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>linux归档 - Liao&#039;s blog</title>
	<atom:link href="https://www.laobaiblog.top/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.laobaiblog.top/tag/linux/</link>
	<description>路漫漫其修远兮，吾将上下而求索</description>
	<lastBuildDate>Tue, 01 Apr 2025 13:40:41 +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>linux归档 - Liao&#039;s blog</title>
	<link>https://www.laobaiblog.top/tag/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</title>
		<link>https://www.laobaiblog.top/2025/04/01/ollama-gguf/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 01 Apr 2025 07:57:35 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[huggingface]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ollama]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=546</guid>

					<description><![CDATA[<p>在 Ubuntu 24.04 上部署 Ollama + DeepSeek，可以构建一个安全、可控的本 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2025/04/01/ollama-gguf/">Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  在 Ubuntu 24.04 上部署 Ollama + DeepSeek，可以构建一个安全、可控的本地 AI 知识库系统，适用于企业文档管理、个人学习助手等场景。本教程将详细介绍安装配置步骤，帮助用户快速搭建属于自己的 AI 知识库，实现高效信息检索与智能交互。
</p></blockquote>
<h3>一、Ollama 下载与部署</h3>
<p>Ollama 是一个开源项目，可以使用官网推荐的脚本方式安装，也可以直接访问 github 下载 release 包后进行手动安装。我这里选择手动安装<code>ollama-linux-amd64.tgz</code></p>
<h4>1. 自动安装</h4>
<pre><code class="language-shell line-numbers">curl -fsSL https://ollama.com/install.sh | sh
</code></pre>
<h4>2. 手动安装</h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f15c1e22299dd452b3c75bd3294b5074.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f15c1e22299dd452b3c75bd3294b5074.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#最新版本在github上查看
wget https://github.com/ollama/ollama/releases/download/v0.6.3/ollama-linux-amd64.tgz
#可以使用以下命令进行解压缩并拷贝到系统目录中：
sudo tar -C /usr -zxvf ollama-linux-amd64.tgz
#这样就直接部署完成了
ollama -v
#显示 ollama version is 0.6.3 查看安装版本进行验证。
</code></pre>
<h4>3. 创建 Ollama 用户及系统服务</h4>
<p>出于安全性、隔离性和系统管理的考虑，需要创建 ollama 用户，执行以下命令：</p>
<pre><code class="language-shell line-numbers"># 新增用户
sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
# 修改用户信息
sudo usermod -a -G ollama <span class="katex math inline">(whoami)
创建系统服务 service 文件：

# 编辑文件
sudo vi /etc/systemd/system/ollama.service
# 文件内容
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=</span>PATH"
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_ORIGINS=*"

[Install]
WantedBy=default.target
</code></pre>
<h4>4. 配置重载及开机自启</h4>
<pre><code class="language-shell line-numbers"># 重载配置
sudo systemctl daemon-reload
# 启动服务
sudo systemctl start ollama.service
# 查看服务状态
sudo systemctl status ollama.service
# 设置服务开机自启动
sudo systemctl enable ollama.service
</code></pre>
<h3>二、Huggingface模型下载</h3>
<p><a class="wp-editor-md-post-content-link" href="https://huggingface.co/">Huggingface官网下载（科学上网）</a></p>
<ol>
<li>ollama因为网络不稳定的原因，所以在这里没有ollama pull XXX模型，在这里根据自身显卡规格选择想要运行的模型，用这两个模型作为参考：</li>
</ol>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://huggingface.co/unsloth/DeepSeek-R1-Distill-Qwen-32B-GGUF/tree/main">unsloth/DeepSeek-R1-Distill-Qwen-32B-GGUF</a></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_cf5a1b7c1d1cd29251b246290255c3cf.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_cf5a1b7c1d1cd29251b246290255c3cf.jpg" alt="" /></a></p>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://huggingface.co/Qwen/QwQ-32B-GGUF">Qwen/QwQ-32B-GGUF</a></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_8add52e0c967508a9cc7032be3132d8c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_8add52e0c967508a9cc7032be3132d8c.jpg" alt="" /></a></p>
<p>下载并上传到服务器<code>/data/models/XXX</code>模型目录下</p>
<pre><code class="language-shell line-numbers">#参数解析
DeepSeek：DeepSeek 发布的模型文件
R1：深度思考模型
Distill：模型蒸馏
Qwen：与阿里巴巴推出的通义千问系列模型相关
32B：32 Billion，即 320 亿参数的版本
Q4：4-bit 量化
K：量化分组，是量化算法中的一种优化技术
M：中等量化粒度
gguf：GPT-Generated Unified Format，是一种专为大型模型设计的二进制文件存储格式
</code></pre>
<h3>三、Ollama手动加载模型运行</h3>
<p>把<strong><code>DeepSeek-R1-Distill-Qwen-32B-Q4_K_M.gguf</code></strong>及<strong><code>qwq-32b-q4_k_m.gguf</code></strong>两个模型文件放到对应的<strong><code>deepseek</code></strong>及<strong><code>qwq</code></strong>目录下。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_84e92d9b67262d046758b6409a1d931c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_84e92d9b67262d046758b6409a1d931c.jpg" alt="" /></a></p>
<h5>1. 在DeepSeek模型文件同级目录下创建文件<code>ollama-deepseek</code>并写入以下内容：</h5>
<pre><code class="language-shell line-numbers">FROM ./DeepSeek-R1-Distill-Qwen-32B-Q4_K_M.gguf
</code></pre>
<pre><code class="language-shell line-numbers">#然后在模型文件目录执行以下命令导入模型文件：
ollama create DeepSeek-R1-Distill-Qwen-32B-GGUF -f ./ollama-deepseek
</code></pre>
<h5>2. 在Qwq模型文件同级目录下创建文件<code>ollama-qwq</code>并写入以下内容：</h5>
<pre><code class="language-shell line-numbers">FROM ./qwq-32b-q4_k_m.gguf
</code></pre>
<pre><code class="language-shell line-numbers">#然后在模型文件目录执行以下命令导入模型文件：
ollama create QwQ-32B-GGUF -f ./ollama-qwq
</code></pre>
<h3>四、查看模型与运行模型</h3>
<p>可以使用命令<code>ollama list</code>查看已加载的模型列表：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_53dcc1feda2e1a8c640041ba809b3a1b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_53dcc1feda2e1a8c640041ba809b3a1b.jpg" alt="" /></a></p>
<p>然后通过命令<code>ollama run &lt;model-name&gt;</code>就可以运行指定的模型了</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_83e2136af7bdf2b143a48fc317a9d51a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_83e2136af7bdf2b143a48fc317a9d51a.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2025/04/01/ollama-gguf/">Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用docker部署pgsql，构建容灾高可用集群</title>
		<link>https://www.laobaiblog.top/2024/09/19/dockerpgbk/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Thu, 19 Sep 2024 07:04:30 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pgpool]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[集群]]></category>
		<category><![CDATA[高可用]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=504</guid>

					<description><![CDATA[<p>postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)，在pos &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/09/19/dockerpgbk/">使用docker部署pgsql，构建容灾高可用集群</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)，在postgresql官网看了<a class="wp-editor-md-post-content-link" href="https://www.pgpool.net/mediawiki/index.php/Documentation">pgpool-II的文档</a>，发现部署比较麻烦，为了方便快捷还是使用docker部署。
</p></blockquote>
<h1>一、简介</h1>
<p><code>bitnami/postgresql-repmgr</code>是<code>PostgreSQL HA</code>对应的docker镜像，<code>PostgreSQL HA</code> 是 PostgreSQL 集群解决方案，其中包括 PostgreSQL 复制管理器，这是一个用于管理 PostgreSQL 集群上的复制和故障转移的开源工具。</p>
<p><code>bitnami/pgpool</code>是<code>Pgpool-II</code> 对应的docker镜像，是 PostgreSQL 代理。它位于 PostgreSQL 服务器和它们的客户端之间，提供连接池、负载平衡、自动故障转移和复制。</p>
<h1>二、部署环境</h1>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li>postgresql Version：postgresql-repmgr:14</li>
<li>pgpool Version：latest</li>
<li>Docker Version：20.10.21</li>
</ul>
<h3>1. 拉取docker镜像</h3>
<p>稳妥起见，这里选用了postgresql 14版本，其次如果遭遇docker镜像拉取网络问题，可以参考我的这篇博文<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/16/docker%e4%bb%93%e5%ba%93%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86%e6%89%93%e9%80%a0%e5%b1%9e%e4%ba%8e%e8%87%aa%e5%b7%b1%e7%9a%84docker-hub/">打造属于自己的Docker Hub镜像代理网站</a>，或者在镜像前加入私有镜像站。</p>
<pre><code class="language-shell line-numbers">docker pull bitnami/postgresql-repmgr:14
docker pull bitnami/pgpool:latest

#私有镜像站eg
docker pull hub-mirror.c.163.com/bitnami/postgresql-repmgr:14
docker pull hub-mirror.c.163.com/bitnami/pgpool:latest
</code></pre>
<h3>2. 启动pgsql数据库</h3>
<ol>
<li>创建文件夹并授权</li>
</ol>
<pre><code class="language-shell line-numbers">cd /
mkdir data
cd data
mkdir repmgr1
mkdir repmgr2
chmod 777 /data/repmgr1
chmod 777 /data/repmgr2
</code></pre>
<ol start="2">
<li>创建docker网络</li>
</ol>
<pre><code class="language-shell line-numbers">docker network create pg-network
</code></pre>
<ol start="3">
<li>启动数据库<br />
为了数据持久化，我们把/bitnami/postgresql目录挂载到/data/repmgr1目录下。以下两条命令可以自行做成bash脚本启动。</li>
</ol>
<pre><code class="language-shell line-numbers">#pg-0数据库启动
docker run -v /data/repmgr1:/bitnami/postgresql --detach --restart always --name pg-0 -p 30350:5432 --network pg-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-0 --env REPMGR_NODE_NETWORK_NAME=pg-0 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=123456 --env POSTGRESQL_PASSWORD=123456 bitnami/postgresql-repmgr:14
</code></pre>
<pre><code class="language-shell line-numbers">#pg-1数据库启动
docker run -v /data/repmgr2:/bitnami/postgresql --detach --restart always --name pg-1 -p 30351:5432 --network pg-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-1 --env REPMGR_NODE_NETWORK_NAME=pg-1 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=123456 --env POSTGRESQL_PASSWORD=123456 bitnami/postgresql-repmgr:14
</code></pre>
<ol start="4">
<li>查看启动状态</li>
</ol>
<pre><code class="language-shell line-numbers">docker ps
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_53c9eb917a6049470cd79aaad78f45c2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_53c9eb917a6049470cd79aaad78f45c2.jpg" alt="" /></a></p>
<h3>3. 启动Pgpool</h3>
<p>注意，这里的<code>--add-host</code>参数对应的IP是你<strong>本地的宿主机IP</strong>，请自行修改。</p>
<pre><code class="language-shell line-numbers">docker run --detach --restart always --name pgpool -p 9999:5432 \
  --env PGPOOL_BACKEND_NODES=0:pg-0:30350,1:pg-1:30351 \
  --env PGPOOL_SR_CHECK_USER=postgres \
  --env PGPOOL_SR_CHECK_PASSWORD=123456 \
  --env PGPOOL_ENABLE_LDAP=no \
  --env PGPOOL_POSTGRES_USERNAME=postgres \
  --env PGPOOL_POSTGRES_PASSWORD=123456 \
  --env PGPOOL_ADMIN_USERNAME=postgres \
  --env PGPOOL_ADMIN_PASSWORD=123456 \
  --add-host=pg-0:192.168.1.204 \
  --add-host=pg-1:192.168.1.204 \
  bitnami/pgpool:latest
</code></pre>
<p>启动成功后，查看pgpool日志，通过pgpool可以实现数据库的负载均衡和读写分离。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_1665dd6bb789f5d7a5650c91028b8746.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_1665dd6bb789f5d7a5650c91028b8746.jpg" alt="" /></a></p>
<h3>4. 测试验证</h3>
<ol>
<li>navicat连接pgpool，创建user表并插入数据，看看<code>pg-0</code>及<code>pg-1</code>是否同步插入。</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_08857131284d85b7fd726fb0d4a5c480.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_08857131284d85b7fd726fb0d4a5c480.jpg" alt="" /></a></p>
<hr />
<p><code>pgpool</code>创建<code>user</code>表，插入数据</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_d61298966092bba2948e0fc3b46626da.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_d61298966092bba2948e0fc3b46626da.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_fb9a7662185c7a42dc7b0ed10ab8928d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_fb9a7662185c7a42dc7b0ed10ab8928d.jpg" alt="" /></a></p>
<ol start="2">
<li>验证：<code>pg-0</code>、<code>pg-1</code>同步插入</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_b71f72be299bfc3ae3136718e6abe34e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_b71f72be299bfc3ae3136718e6abe34e.jpg" alt="" /></a></p>
<p>以上方法非常简单，最后程序直接访问9999端口即可实现读写分离。</p>
<p><strong>缺点：<br />
只能再一个宿主机上执行，不能跨主机。Pgpool和Pgsql有更多的高可用方法，后续还可以深入，多服务器部署及新增组件等。</strong></p>
<p>参考地址：<br />
<a class="wp-editor-md-post-content-link" href="https://www.pgpool.net/mediawiki/index.php/Documentation">官网WIKI</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/applerosa/p/13160566.html">postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/hacker-linner/p/16173012.html">pgpool-II 4.3 中文手册</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/qgdtq/p/17106567.html">Postgresql通过docker进行高可用部署<br />
</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/eternityCulture/p/17528840.html">使用docker部署pg集群（postgresql+postgis+pgrouting+pgpool）</a></p>
<p><a href="https://www.laobaiblog.top/2024/09/19/dockerpgbk/">使用docker部署pgsql，构建容灾高可用集群</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</title>
		<link>https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 09 Jul 2024 07:02:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[openssl]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=481</guid>

					<description><![CDATA[<p>Openssh经过一段时间的等保测试，看来又得重新升级。略微删减了一下脚本，在离线环境中使用。 相关 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>Openssh经过一段时间的等保测试，看来又得重新升级。略微删减了一下脚本，在离线环境中使用。</em></p>
<h3>相关环境</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_b07c39eeaf26c7ab4682643f5f4515e4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_b07c39eeaf26c7ab4682643f5f4515e4.jpg" alt="" /></a></p>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li><a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/">OpenSSH版本</a> : 7.4p1 &#8212;> <a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/">9.8p1</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/old/1.1.1/index.html">OpenSSL版本</a> ：1.0.2k &#8212;> <a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/openssl-1.1.1w.tar.gz">1.1.1w</a></li>
<li>zlib版本(需要外网下载，根据需要更换版本)：<a class="wp-editor-md-post-content-link" href="http://www.zlib.net/zlib-1.3.1.tar.gz">1.3.1</a></li>
</ul>
<h3>Openssh离线安装升级</h3>
<ul>
<li><strong><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/i0vwY23zevab">蓝奏云下载</a></strong> (离线安装包也已经整理好相关脚本依赖，防止CSDN白嫖党，解压密码：laobai)</li>
</ul>
<p>文中常用命令：</p>
<pre><code class="language-shell line-numbers">#查看Linux信息
[root@asdasd ~] uname -a
Linux ZKHY 3.10.0-1160.62.1.el7.x86_64 1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
#查看centos版本
[root@asdasd ~] cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
#查看ssh版本
[root@adasd ~] ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
#创建脚本安装目录
[root@asdasd ~]mkdir -p /root/OpenSSH
</code></pre>
<h4><strong>1. 将脚本解压放到<code>/root/OpenSSH</code>下。</strong></h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a0e52f483aa36d9df645ad23c70ef4b5.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a0e52f483aa36d9df645ad23c70ef4b5.jpg" alt="" /></a></p>
<h4><strong>2. 授权脚本运行升级Openssh及Openssl,静待升级即可。</strong></h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_eaade98e038fc094bb60fa7bd0141f7b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_eaade98e038fc094bb60fa7bd0141f7b.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#进入安装目录
[root@asdasd ~]# cd /root/OpenSSH/
[root@asdasd OpenSSH]# ll
total 13024
-rw-r--r-- 1 root root 1910393 Jul  9 14:38 openssh-9.8p1.tar.gz
-rw-r--r-- 1 root root 9893384 Jul  9 14:38 openssl-1.1.1w.tar.gz
drwxr-xr-x 3 root root    4096 Jul  9 14:38 packages
-rw-r--r-- 1 root root    5590 Jul  9 14:38 UpdateOpenSSH.sh
-rw-r--r-- 1 root root 1512791 Jul  9 14:38 zlib-1.3.1.tar.gz
#授权脚本执行权限
[root@asdasd OpenSSH]# chmod a+x UpdateOpenSSH.sh
#运行升级脚本
[root@asdasd OpenSSH]# ./UpdateOpenSSH.sh
</code></pre>
<h3>升级效果</h3>
<pre><code class="language-shell line-numbers">#输入命令查看升级效果
ssh -V
OpenSSH_9.8p1, OpenSSL 1.1.1w  11 Sep 2023
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_1365d8240319cd0ef00abd7fdb36661b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_1365d8240319cd0ef00abd7fdb36661b.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</title>
		<link>https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Mon, 15 Jan 2024 07:50:02 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[域名]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=462</guid>

					<description><![CDATA[<p>一、理论概述 ChatGpt接口目前只能在国外互联网环境中使用，国内想要使用相关服务的话可以寻求代理 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/">使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3>一、理论概述</h3>
<p>ChatGpt接口目前只能在国外互联网环境中使用，国内想要使用相关服务的话可以寻求代理，在这里使用的是一台国外服务器安装Nginx服务进行相关代理。</p>
<h3>二、环境要求</h3>
<ul>
<li>一台拥有公网IP的国外服务器</li>
<li>一个域名及免费ssl证书（可在腾讯云免费申请ssl证书）</li>
<li>一个ChatGpt账号及相关的<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/api-keys">APIkey</a></li>
</ul>
<p>以上就是所有需要用到的环境，<strong><em>请注意，如要使用接口还需要<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/account/billing/overview">充值API</a>额度</em></strong>。除此之外还需要将你的域名解析到公网IP上。完成准备工作后进行以下操作。</p>
<h3>三、Nginx转发</h3>
<ol>
<li>在服务器中安装nginx，这里使用的是docker服务，根据以往博文中可自行安装Docker服务。</li>
</ol>
<pre><code class="language-shell line-numbers">#服务器中新建一个nginx目录，下级目录新建conf.d、logs、ssl三个目录
mkdir -p nginx/conf.d
mkdir -p nginx/logs
mkdir -p nginx/ssl

#在nginx目录中新建start.sh脚本
vim start.sh

docker stop nginx
docker rm nginx
docker run  -p 80:80  -p 443:443 --name nginx --net=host  --restart=always  --privileged=true \
    -v `pwd`/conf.d/:/etc/nginx/conf.d \
    -v `pwd`/logs/:/var/log/nginx  \
    -v `pwd`/ssl/:/var/ssl \
    -e TZ="Asia/Shanghai" \
    nginx:latest

#输入 :wq 保存后授权并执行即可
chmod a+x start.sh
./start.sh
</code></pre>
<ol start="2">
<li>将域名ssl证书放置在ssl目录下后，编辑nginx转发代理，执行<code>start.sh</code>脚本重启nginx服务。</li>
</ol>
<pre><code class="language-shell line-numbers">vim conf.d/gpt.conf

#填入域名信息
server {
        listen       443 ssl;
        server_name  域名;
        ssl_certificate /var/ssl/域名.crt;     #配置证书位置
        ssl_certificate_key /var/ssl/域名.key; #配置秘钥位置】

        ssl_session_timeout 5m;
        ssl_protocols SSLv2 SSLv3 TLSv1.2;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers on;

        underscores_in_headers on;
        charset utf-8;

        location /v1/ {
             proxy_ssl_server_name on;
             proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
             proxy_pass https://api.openai.com;
        }
}
</code></pre>
<p>以上便完成了针对chatgpt接口地址 <strong><em><code>api.openai.com</code></em></strong> 的转发工作，转发后的地址既是你的域名。</p>
<h3>四、Java实例调用实现多轮对话</h3>
<ol>
<li>新建Maven项目ChatGPTClient，在<code>pom.xml</code>中添加后续用到的依赖，重构后拉取。</li>
</ol>
<pre data-language=XML><code class="language-markup line-numbers">&lt;dependency&gt;
            &lt;groupId&gt;com.squareup.okhttp3&lt;/groupId&gt;
            &lt;artifactId&gt;okhttp&lt;/artifactId&gt;
            &lt;version&gt;4.9.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
            &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
            &lt;artifactId&gt;gson&lt;/artifactId&gt;
            &lt;version&gt;2.8.9&lt;/version&gt; &lt;!-- 使用最新的可用版本 --&gt;
&lt;/dependency&gt;
</code></pre>
<ol start="2">
<li>java代码</li>
</ol>
<pre><code class="language-shell line-numbers">import okhttp3.*;
import com.google.gson.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ChatGPTClient {
    private final String apiKey;
    private final OkHttpClient client;
    private final List&lt;Message&gt; messages;
    private final Gson gson;
    private int tokenCount = 0;
    private int inputTokenCount = 0;
    private int outputTokenCount = 0;

    public ChatGPTClient(String apiKey) {
        this.apiKey = apiKey;
        this.client = new OkHttpClient();
        this.messages = new ArrayList&lt;&gt;();
        this.gson = new Gson();
    }

    public String sendMessage(String message) throws IOException {
        updateTokenCount(message, true);

        messages.add(new Message("system", "user", message));
//model模型选择可以有gpt-3.5-turbo、gpt-4、gpt-4-turbo价格以此类推
        RequestBody body = RequestBody.create(
                MediaType.get("application/json; charset=utf-8"),
                "{\"model\": \"gpt-3.5-turbo\", \"messages\": " + gson.toJson(messages) + "}"
        );

        Request request = new Request.Builder()
                .url("https://你的域名地址/v1/chat/completions")
                .addHeader("Authorization", "Bearer " + this.apiKey)
                .addHeader("Content-Type", "application/json")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            JsonObject respJson = JsonParser.parseString(response.body().string()).getAsJsonObject();
            JsonArray choices = respJson.getAsJsonArray("choices");
            if (choices != null &amp;&amp; choices.size() &gt; 0) {
                JsonObject firstChoice = choices.get(0).getAsJsonObject();
                String aiResponse = firstChoice.getAsJsonObject("message").get("content").getAsString();

                updateTokenCount(aiResponse, false);

                messages.add(new Message("system", "assistant", aiResponse));

                System.out.println("输入的 Token 数: " + inputTokenCount);
                System.out.println("输出的 Token 数: " + outputTokenCount);
                System.out.println("总使用的 Token 数: " + tokenCount);

                return aiResponse;
            }
        }
        return "无法获取响应。";
    }

    private void updateTokenCount(String text, boolean isInput) {
        int count = 0;
        for (char c : text.toCharArray()) {
            count += (String.valueOf(c).matches("[\\u0000-\\u00ff]") ? 1 : 4);
        }
        int tokens = (int) Math.ceil(count / 4.0);
        tokenCount += tokens;
        if (isInput) {
            inputTokenCount += tokens;
        } else {
            outputTokenCount += tokens;
        }
    }

    private static class Message {
        String role;
        String content;

        public Message(String type, String role, String content) {
            this.role = role;
            this.content = content;
        }
    }

    public static void main(String[] args) throws IOException {
        ChatGPTClient client = new ChatGPTClient("YOUR-API-KEY");

        Scanner scanner = new Scanner(System.in, "UTF-8");
        String input;
        while (true) {
            System.out.print("输入消息（输入 'bye' 结束对话）: ");
            input = scanner.nextLine();
            if ("bye".equalsIgnoreCase(input)) {
                break;
            }
            String response = client.sendMessage(input);
            System.out.println("ChatGPT 回应: " + response);
        }
    }
}

</code></pre>
<p>在以上代码中，增加了每次对话后所使用的token值，以便查询核对接口使用费。可在官网查询相关定价。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_7ca6ffab890759733ec128bda9db6a20.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_7ca6ffab890759733ec128bda9db6a20.jpg" alt="" /></a></p>
<h3>五、运行结果</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_86a520f2c97f583072037ca931be6455.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_86a520f2c97f583072037ca931be6455.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/">使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</title>
		<link>https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 22 Nov 2023 06:08:25 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[zlib]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=439</guid>

					<description><![CDATA[<p>前言：近期等保出现了openssh相关漏洞，所以改了一下之前的在线升级脚本，将Openssh升级至9 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>前言：近期等保出现了openssh相关漏洞，所以改了一下之前的在线升级脚本，将Openssh升级至9.5p1，OpenSSL升级至1.1.1w，已测试放心食用。</em></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">已更新最新OpenSSH9.8p1</a></p>
<h3>相关环境</h3>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li>OpenSSH版本: <a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz">9.5p1</a></li>
<li>OpenSSL版本：<a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/openssl-1.1.1w.tar.gz">1.1.1w</a></li>
<li>zlib版本(需要外网下载，根据需要更换版本)：<a class="wp-editor-md-post-content-link" href="http://www.zlib.net/zlib-1.3.1.tar.gz">1.2.12</a></li>
</ul>
<h3>联网升级安装</h3>
<p><strong><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/igONT1flluxc">脚本蓝奏云下载</a></strong>（离线安装包也已经整理好相关脚本依赖，防止CSDN白嫖党，解压密码：laobai）</p>
<pre><code class="language-shell line-numbers">#创建安装目录
mkdir -p /root/OpenSSH/zlib/
</code></pre>
<p><strong>将zlib-1.2.12.tar.gz依赖包上传至/root/OpenSSH/zlib/目录下运行压缩包中的脚本即可</strong></p>
<pre><code class="language-shell line-numbers">#将脚本放入/root/OpenSSH目录下
cd /root/OpenSSH

#将下段代码复制粘贴后授权运行即可
chmod a+x UpdateOpenSSH.sh
./UpdateOpenSSH.sh
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/iOH1o1flp0oh"><strong>脚本下载</strong></a>（网页可能会有符号替换，不建议复制）</p>
<pre><code class="language-shell line-numbers">#!/bin/bash

clear
echo ------------------------------------------
echo        CentOS7 openssh升级到9.5p1
echo              <span class="katex math inline">(date +%F-%T)
echo         注意环境，使用前请做好测试！！！
echo ------------------------------------------
sleep 3s
clear
echo 安装进程开始  3
sleep 1s
clear
echo 安装进程开始  3  2
sleep 1s
clear
echo 安装进程开始  3  2  1
sleep 1s
clear
echo 刷新yum元数据缓存
sleep 2s

yum makecache
sleep 3s
clear
echo 检测安装telnet服务
sleep 1s
echo 尝试启动telnet服务
sleep 1s
cp /etc/securetty /etc/securetty.bak
grep  "pts/0"  /etc/securetty ||  echo 'pts/0' >> /etc/securetty
grep  "pts/1"  /etc/securetty ||  echo 'pts/1' >> /etc/securetty
systemctl restart telnet.socket &&  systemctl restart xinetd
ps -ef |grep xinetd | egrep -v grep > /dev/null
if [</span>? -eq 0 ]
then
    echo 检测到telnet服务已启动……
    systemctl enable telnet.socket
    systemctl enable xinetd
        sleep 2s
else
    echo 未检测到telnet服务，开始安装服务……
    sleep 2s
    yum -y install xinetd telnet-server
    sleep 2s
    clear
    echo 安装telnet服务结束，启动服务……
    systemctl restart telnet.socket &&  systemctl restart xinetd
    systemctl enable telnet.socket
    systemctl enable xinetd
    sleep 1s
fi
clear
echo 关闭SElinux及防火墙并禁用……
sleep 2s
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
cat /etc/selinux/config
systemctl stop firewalld.service
systemctl disable firewalld.service
sleep 2s
clear
echo 安装程序依赖包……
sleep 2s
#yum -y localinstall ls packages/*.rpm
yum -y install gcc gcc-c++ make pam pam-devel openssl-devel pcre-devel perl zlib-devel
sleep 1s
clear
echo 停止并卸载原有ssh
sleep 3s
systemctl stop sshd
cp -r /etc/ssh /etc/ssh.old
cp -r /etc/init.d/ssh /etc/init.d/ssh.old
rpm -qa | grep openssh
sleep 1s
rpm -e `rpm -qa | grep openssh` --nodeps
rpm -qa | grep openssh
sleep 1s
clear

echo 判断是否需要安装wget
WGET=`rpm -qa | grep wget`
if [<span class="katex math inline">WGET -z ];then
    yum install -y wget
fi
echo 准备文件和参数
echo ################################################################
echo 服务器无法联网下载的可以将所需要的升级包放到/root/OpenSSH目录下
echo ################################################################
file=/root/OpenSSH
#zlib=http://www.zlib.net/zlib-1.2.12.tar.gz
openssl=https://www.openssl.org/source/openssl-1.1.1w.tar.gz
openssh=https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz 
echo 创建目录
mkdir -p</span>file/zlib
mkdir -p <span class="katex math inline">file/openssl
mkdir -p</span>file/openssh
echo 联网通过wget下载安装包
cd <span class="katex math inline">file
#echo 开始下载zlib
#wget</span>zlib
echo 开始下载openssl
wget --no-check-certificate <span class="katex math inline">openssl
echo 开始下载openssh
wget --no-check-certificate</span>openssh
###安装相关依赖包###
yum install -y gcc make perl zlib zlib-devel pam pam-devel

echo 安装zlib
sleep 2s
tar -xzf zlib*.tar.gz -C <span class="katex math inline">file/zlib 
sleep 2s
cd</span>file/zlib/zlib*
./configure --prefix=/usr/local/zlib && make && make install
ls -l /usr/local/zlib
cd ..
sleep 1s
clear
echo 配置zlib
grep  "/usr/local/zlib/lib"  /etc/ld.so.conf.d/zlib.conf ||  echo '/usr/local/zlib/lib' >> /etc/ld.so.conf.d/zlib.conf
ldconfig -v
sleep 1s
clear
echo 安装openssl
sleep 5s
mv -f /usr/bin/openssl /usr/bin/openssl.old
mv -f /usr/include/openssl /usr/include/openssl.old
mv -f /usr/lib64/openssl /usr/lib64/openssl.old
rm -rf /usr/local/ssl
cd <span class="katex math inline">file
tar -xzf openssl*.tar.gz -C</span>file/openssl
cd <span class="katex math inline">file/openssl/openssl*
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && make && make install
cd ..
sleep 5s
clear
echo 配置openssl
sleep 5s
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
grep  "/usr/local/ssl/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/ssl/lib' >> /etc/ld.so.conf.d/ssl.conf
grep  "/usr/local/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/lib' >> /etc/ld.so.conf.d/ssl.conf
ldconfig -v
openssl version -a
sleep 5s
clear
echo 安装openssh
sleep 5s
rm -rf /etc/ssh
cd</span>file
tar -xzf openssh*.tar.gz -C <span class="katex math inline">file/openssh
cd</span>file/openssh/openssh*
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl   --with-zlib --with-md5-passwords
make
sleep 5s
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
make install
cd ..
pwd
sleep 5s
clear
echo 配置openssh
sleep 10s
echo "PasswordAuthentication yes"   >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo 'Banner /etc/issue' >> /etc/ssh/sshd_config
cp -p openssh-9.5p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
chkconfig --add sshd
chkconfig sshd on
systemctl restart sshd
sleep 10s
clear
systemctl status sshd
if [ $? -eq 0 ]
then
    clear
    echo SSH安装并运行成功，开始关闭并禁用telnet
    sleep 1s
    systemctl stop telnet.socket &&  systemctl stop xinetd
    systemctl disable telnet.socket &&  systemctl disable xinetd
    sleep 1s
    echo 升级完成,安装ssh2扩展支持
    sleep 5s
    yum install libssh2 -y
    clear
    echo 安装进程结束
    sleep 5s
else
    echo SSH未成功安装或配置，安装进程即将退出，请检查日志……
    sleep 5s
fi

</code></pre>
<h3>升级成功</h3>
<pre><code class="language-shell line-numbers">#输入命令查看升级效果
ssh -V
OpenSSH_9.5p1, OpenSSL 1.1.1w  11 Sep 2023
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/11/wp_editor_md_4c74046be04e58d1cfd0c80ae1ed264d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/11/wp_editor_md_4c74046be04e58d1cfd0c80ae1ed264d.jpg" alt="" /></a></p>
<ul>
<li>这是我之前的博文：<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/04/01/centos-7-%e7%a6%bb%e7%ba%bf%e6%9b%b4%e6%96%b0%e5%8d%87%e7%ba%a7-openssh-8-8p1/">CentOS 7 离线更新升级 openSSH 8.8p1</a></li>
<li>另附手动升级博文：<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/simendavid/archive/2023/10/27/17792570.html#!comments">湖南馒头:CentOS7 OpenSSL升级1.1.1w；OpenSSH 升级 9.5p1 保姆级教程 </a></li>
</ul>
<p><a href="https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</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>
		<item>
		<title>Docker安装nps实现[OpenWrt]内网穿透</title>
		<link>https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 02 Nov 2022 06:36:43 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nps]]></category>
		<category><![CDATA[openwrt]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[内网穿透]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=334</guid>

					<description><![CDATA[<p>一、NPS 概述 NPS 是一款轻量级、功能强大的内网穿透代理服务器。支持 tcp、udp 流量转发 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/">Docker安装nps实现[OpenWrt]内网穿透</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3>一、NPS 概述</h3>
<p>NPS 是一款轻量级、功能强大的内网穿透代理服务器。支持 tcp、udp 流量转发，支持内网 http 代理、内网 socks5 代理，同时支持 snappy 压缩、站点保护、加密传输、多路复用、header 修改等。支持 web 图形化管理，集成多用户模式。管理系统比 FRP 方便很多，更容易上手。</p>
<h3>二、配置要求</h3>
<ul>
<li>一台拥有公网 IP 的服务器。</li>
<li>开放端口例如：(8080,8024,80,443）等可以不是这些端口，nps可以配置任意端口，实现与其它服务共存。</li>
</ul>
<h3>三、相关文档</h3>
<ul>
<li>NPS 配置文档：https://ehang-io.github.io/nps/#/</li>
<li>NPS 安装包：https://github.com/ehang-io/nps/releases</li>
<li>NPS 源码：https://github.com/ehang-io/nps</li>
</ul>
<h3>四、环境说明</h3>
<ul>
<li>服务器端是我的Ubuntu(arm)云服务器；</li>
<li><strong>客户端是本地N1盒子Openwrt系统的nps插件（无需安装客户端）</strong>。</li>
</ul>
<h3>五、演示安装</h3>
<h4>1. 服务端</h4>
<ul>
<li><strong>Docker拉取Nps镜像</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#拉取nps镜像
docker pull ffdfgdfg/nps
#创建nps配置文件目录
mkdir -p /root/nps/conf
</code></pre>
<ul>
<li>github下载配置文件，<strong>将nps-master下的conf文件拷贝至服务器上的/root/nps/conf目录下</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_265c4dd6295be6b20c0ebbaea52b7f2f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_265c4dd6295be6b20c0ebbaea52b7f2f.jpg" alt="" /></a></p>
<p><span id="more-334"></span></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_5f324c40e1444e06a3980f7f451b335a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_5f324c40e1444e06a3980f7f451b335a.jpg" alt="" /></a></p>
<ul>
<li><strong>修改nps.conf配置</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#编辑nps.conf
vim /root/nps/conf/nps.conf

#nps.conf
appname = nps
runmode = dev

http_proxy_ip=0.0.0.0
http_proxy_port=19000
https_proxy_port=19001
https_just_proxy=true

https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key

bridge_type=tcp
bridge_port=19002
bridge_ip=0.0.0.0

public_vkey=123

log_level=7

web_host=a.o.com
web_username=admin
web_password=123
web_port = 19003
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
auth_crypt_key =1234567887654321
allow_user_login=false
allow_user_register=false
allow_user_change_username=false
allow_flow_limit=false
allow_rate_limit=false
allow_tunnel_num_limit=false
allow_local_proxy=false
allow_connection_num_limit=false
allow_multi_ip=false
system_info_display=false
http_cache=false
http_cache_length=100
http_add_origin_header=false[object Object]


</code></pre>
<ul>
<li><strong>docker启动nps，注意防火墙是否开放相关端口</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#启动nps，端口开放19000-19010
docker run -d -p 19000-19010:19000-19010 -v /root/nps/conf:/conf --name=nps --restart=always ffdfgdfg/nps
</code></pre>
<ul>
<li><strong>访问Nps后台：http://IP:19003 默认账号密码是配置文件中的admin/123(可自行更改)。</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_dc27a065af42956f136ee1424fd069e9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_dc27a065af42956f136ee1424fd069e9.jpg" alt="" /></a></p>
<ul>
<li><strong>创建nps客户端及tcp隧道</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_1f47862aa69dd09a9dd397316ba0d9cc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_1f47862aa69dd09a9dd397316ba0d9cc.jpg" alt="" /></a></p>
<p><!--more--></p>
<p>创建客户端，点击客户端详情查看 <strong>-server/-key</strong> 两个参数。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_3e67ef83c08e03524f834e442df1a1a9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_3e67ef83c08e03524f834e442df1a1a9.jpg" alt="" /></a></p>
<h4>2. 客户端</h4>
<ul>
<li><strong>进入内网OpenWrt，打开nps插件，输入server及key参数保存，在服务端即可发现客户端已连接。</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_fa3e4010917fd1997f207478acc8c24f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_fa3e4010917fd1997f207478acc8c24f.jpg" alt="" /></a></p>
<h4>3. 配置转发</h4>
<ul>
<li><strong>查看客户端状态</strong></li>
</ul>
<p>此处可以看到一个客户端ID为6，连接状态为在线。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_701405fdb3565a5c8c329c7b615ee226.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_701405fdb3565a5c8c329c7b615ee226.jpg" alt="" /></a></p>
<ul>
<li><strong>添加tcp隧道转发</strong></li>
</ul>
<p>如下配置表示<strong>将服务端的1XXX6端口转发到局域网内192.168.50.1/3的80/5244等端口</strong>。其他的UDP、SOCKS、HTTP也是类似的配置不再赘述。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_7a46b904fdeb607003c0270434ee4951.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_7a46b904fdeb607003c0270434ee4951.jpg" alt="" /></a></p>
<h4>4. 总结</h4>
<p>NPS及OpenWrt的配置安装都很便捷，如果你有一台自己的VPS云服务器，可以尝试一下，将你的家庭本地电脑映射到外网服务器。<strong>访问公网IP+对应1XXXX端口即可访问到内网对应服务。</strong></p>
<h4>5. 参考文章</h4>
<p>不同的安装环境可以看看其他博文：</p>
<p>超详细openwrt内网穿透-nps小白教程：https://vpsxb.net/419/<br />
软路由openwrt之nps内网穿透插件服务：https://www.vjsun.com/424.html<br />
nps实现内网穿透，电脑免费变云服务器：https://tangly1024.com/article/nps-centos-nat-traversal<br />
N1盒子op系统nps内网穿透对接腾讯云傻妞：https://blog.csdn.net/hebine7/article/details/122373365<br />
docker安装nps实现内网穿透：https://5616760.com/docker/nps/2021/08/09/docker-nps.html</p>
<p><a href="https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/">Docker安装nps实现[OpenWrt]内网穿透</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>强烈推荐Alist网盘聚合工具&#124;挂载阿里云盘 谷歌云盘 天翼云盘等实现云Nas影片库</title>
		<link>https://www.laobaiblog.top/2022/09/30/%e5%bc%ba%e7%83%88%e6%8e%a8%e8%8d%90alist%e7%bd%91%e7%9b%98%e8%81%9a%e5%90%88%e5%b7%a5%e5%85%b7%e5%ae%9e%e7%8e%b0%e4%ba%91nas%e5%bd%b1%e7%89%87%e5%ba%93/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Fri, 30 Sep 2022 08:42:15 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[alist]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[天翼云盘]]></category>
		<category><![CDATA[网盘]]></category>
		<category><![CDATA[谷歌网盘]]></category>
		<category><![CDATA[阿里云盘]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=317</guid>

					<description><![CDATA[<p>如今想要搭建一个家庭影音库，必备nas主机及海量硬盘存储空间，随之而来的就是预算爆表。如果能把所有的 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/09/30/%e5%bc%ba%e7%83%88%e6%8e%a8%e8%8d%90alist%e7%bd%91%e7%9b%98%e8%81%9a%e5%90%88%e5%b7%a5%e5%85%b7%e5%ae%9e%e7%8e%b0%e4%ba%91nas%e5%bd%b1%e7%89%87%e5%ba%93/">强烈推荐Alist网盘聚合工具|挂载阿里云盘 谷歌云盘 天翼云盘等实现云Nas影片库</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>如今想要搭建一个家庭影音库，必备nas主机及海量硬盘存储空间，随之而来的就是预算爆表。如果能把所有的网盘聚合在一起，通过网络协议，在电视端就能访问云盘库里的影片，就实现了低成本影片库，还非常方便维护。</em></p>
<h1>Alist 简介</h1>
<p><strong><a class="wp-editor-md-post-content-link" href="https://alist.nn.ci/zh/guide/">Alist</a> 一个支持多种存储，支持网页浏览和 WebDAV 的文件列表程序，由 gin 和 Solidjs 驱动。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_9a373e7390447fb4a35ad1ee01478f7a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_9a373e7390447fb4a35ad1ee01478f7a.jpg" alt="" /></a></p>
<p>Alist V3版本官网使用指南(V2已不再维护)：https://alist.nn.ci/zh/guide/</p>
<h1>Alist 安装</h1>
<ul>
<li>安装docker</p>
</li>
<li>
<p>安装alist镜像并启动</p>
</li>
</ul>
<pre><code class="language-shell line-numbers">#docker安装alist最新版
docker run -d --restart=always -v /etc/alist:/opt/alist/data -p 5244:5244 --name="alist" xhofe/alist:latest
#查看admin初始化密码
docker logs alist
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_771b2d4a66bdc948e9defcccfeafa151.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_771b2d4a66bdc948e9defcccfeafa151.jpg" alt="" /></a></p>
<h1>访问 Alist</h1>
<ol>
<li><strong>通过访问 http://IP:5244/login 输入账号admin及初始密码登录后台。</strong></li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_05374e0967fa1a81c9ef976820e6bec1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_05374e0967fa1a81c9ef976820e6bec1.jpg" alt="" /></a></p>
<ol start="2">
<li><strong>按照<a class="wp-editor-md-post-content-link" href="https://alist.nn.ci/zh/guide/">官网指南</a>添加对应网盘</strong></li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_7d4dffb8b58a58dd17d56787009f6aca.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_7d4dffb8b58a58dd17d56787009f6aca.jpg" alt="" /></a></p>
<h4>阿里云盘</h4>
<ol>
<li>编写路径</li>
<li>根目录可以写成root</li>
<li>获取refresh token</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_8cf94fe46448e0053efc3d698db1e647.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_8cf94fe46448e0053efc3d698db1e647.jpg" alt="" /></a></p>
<h4>天翼云盘</h4>
<ol>
<li>编写路径</li>
<li>手机号</li>
<li>云盘密码</li>
<li>默认-11</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_7f04ad185d471c47a72d5c2f2de92672.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_7f04ad185d471c47a72d5c2f2de92672.jpg" alt="" /></a></p>
<h4>谷歌云盘</h4>
<p>下列所需参数可根据指南获取（ps:谷歌云盘可支持团队盘，无限容量）</p>
<ol>
<li>编写路径</li>
<li>刷新令牌</li>
<li>客户端Id</li>
<li>客户端密钥</li>
<li>分享目录id</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_0b5a8998c792ec9ff568250b098d8077.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_0b5a8998c792ec9ff568250b098d8077.jpg" alt="" /></a></p>
<p><strong>最终如下图所示：</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_d75ecf2a227d814def4ddafae4aa66ff.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_d75ecf2a227d814def4ddafae4aa66ff.jpg" alt="" /></a><br />
<span id="more-317"></span><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_5af802265371bf840c33fb37c76cd231.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_5af802265371bf840c33fb37c76cd231.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_46bbe3ef3ec94e95a1edbc628ff88ea1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_46bbe3ef3ec94e95a1edbc628ff88ea1.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_1fea8f80fef8409f9f713a14fb6d86d7.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_1fea8f80fef8409f9f713a14fb6d86d7.jpg" alt="" /></a></p>
<h1>安装 Kodi实现云播放</h1>
<ul>
<li>进入【Enter files section】</li>
</ul>
<p><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/微信图片_20220930162658.jpg" alt="" /></p>
<ul>
<li>点击【Add videos&#8230;】</li>
</ul>
<p><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/微信图片_20220930162956.jpg" alt="" /></p>
<ul>
<li>点击【Add network location&#8230;】</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_94e47e9dbe0533ae03b539a7e2382243.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_94e47e9dbe0533ae03b539a7e2382243.jpg" alt="" /></a></p>
<ul>
<li>选择【WebDAV server(http)】协议</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_40e6c73517b7b41f532e3ceec2161b76.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_40e6c73517b7b41f532e3ceec2161b76.jpg" alt="" /></a></p>
<ul>
<li>输入alist对应IP端口及admin账号密码即可，自定义命名，我在这里命令为<strong>alist</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_85de4fbcef6db418499d480aafaf2af1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_85de4fbcef6db418499d480aafaf2af1.jpg" alt="" /></a></p>
<h3>kodi 播放</h3>
<ul>
<li>进入alist</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b8f366079744e17f440162898030916f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b8f366079744e17f440162898030916f.jpg" alt="" /></a></p>
<ul>
<li>选择某个云盘</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_e762cfdab7fe84cff6e386459ebb4714.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_e762cfdab7fe84cff6e386459ebb4714.jpg" alt="" /></a></p>
<ul>
<li>播放T-34坦克</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b3c15277352b3f0b1646121a0ea0237b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b3c15277352b3f0b1646121a0ea0237b.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_492573e4d6b83463f015311fc04f5869.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_492573e4d6b83463f015311fc04f5869.jpg" alt="" /></a></p>
<p><strong>完美实现低成本影音库网，盘容量足够看几辈子的影片了，kodi应用手机电视都可安装。ios使用nplayer</strong></p>
<p><a href="https://www.laobaiblog.top/2022/09/30/%e5%bc%ba%e7%83%88%e6%8e%a8%e8%8d%90alist%e7%bd%91%e7%9b%98%e8%81%9a%e5%90%88%e5%b7%a5%e5%85%b7%e5%ae%9e%e7%8e%b0%e4%ba%91nas%e5%bd%b1%e7%89%87%e5%ba%93/">强烈推荐Alist网盘聚合工具|挂载阿里云盘 谷歌云盘 天翼云盘等实现云Nas影片库</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>远程连接Centos7桌面功能</title>
		<link>https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Mon, 05 Sep 2022 10:03:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Xfce]]></category>
		<category><![CDATA[远程桌面]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=277</guid>

					<description><![CDATA[<p>突如其来的疫情让人措手不及，愿疫情早日过去&#8230; 因为要是实现居家办公，公司的服务器有些工作 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/">远程连接Centos7桌面功能</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>突如其来的疫情让人措手不及，愿疫情早日过去&#8230;</em><br />
<em>因为要是实现居家办公，公司的服务器有些工作需要桌面化才能满足日常使用要求</em></p>
<h1>远程连接CentOS7桌面方案</h1>
<p><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouy.com/it82e0b3pseh">MobaXterm工具蓝奏云下载</a></p>
<h3>SSH + X11桌面远程</h3>
<p>Linux的远程桌面一般采用VNC，很少提到SSH + X11做转发，下面介绍多种SSH + X11；</p>
<ul>
<li>安装Xfce桌面</li>
</ul>
<pre><code class="language-shell line-numbers">#安装Xfce
yum -y groupinstall "X Window System" "Xfce"
#启动桌面
startxfce4
</code></pre>
<ul>
<li>MobaXterm转发X11</li>
</ul>
<ol>
<li>MobaXterm功能非常全，内建X server，可远程运行X窗口程序，支持VNC/RDP/Xdmcp等远程桌面；</p>
</li>
<li>
<p>在SSH服务器中配置X11转发服务<br />
在/etc/ssh/sshd_config文件中将 X11Forwarding 设置成 yes</p>
</li>
</ol>
<p><code>X11Forwarding yes</code></p>
<p>重启ssh相关命令</p>
<pre><code class="language-shell line-numbers">#查看ssh服务状态
systemctl status sshd.service

#开启ssh服务
systemctl start sshd.service

#设置ssh服务开机自启
systemctl enable sshd.service
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_3ddb2904cb3a4ae54ea3402ad19b3bb0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_3ddb2904cb3a4ae54ea3402ad19b3bb0.jpg" alt="" /></a></p>
<ol start="3">
<li>配置MobaXterm登录信息(Remote environment注意CentOS的桌面类型 )</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b6667f76c9b7497a0f69fdc484f3cff3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b6667f76c9b7497a0f69fdc484f3cff3.jpg" alt="" /></a></p>
<ol start="4">
<li>MobaXterm连接到服务器<br />
X11-forwarding 和 DISPLAY 都打钩表示配置正常</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_20e20ee8af40a31abb81d48990ff287b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_20e20ee8af40a31abb81d48990ff287b.jpg" alt="" /></a></p>
<h3>远程效果</h3>
<p>这样就可以很方便的使用内网应用了</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_708ff87ef5c2eed595989189ca7eacdc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_708ff87ef5c2eed595989189ca7eacdc.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/">远程连接Centos7桌面功能</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS Docker环境部署Nessus漏洞扫描 系列一</title>
		<link>https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 31 Aug 2022 04:14:00 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nessus]]></category>
		<category><![CDATA[漏洞扫描]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=271</guid>

					<description><![CDATA[<p>一、Docker部署Nessus 部署环境 操作系统版本：CentOS Linux release  &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/">CentOS Docker环境部署Nessus漏洞扫描 系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>一、Docker部署Nessus</h1>
<h2>部署环境</h2>
<ul>
<li>操作系统版本：CentOS Linux release 7.9.2009 (Core)</li>
<li>Docker版本：Docker Server Version: 20.10.17</li>
<li>Nessus版本： 10.3.0 （#80） Linux</li>
</ul>
<h2>部署Nessus</h2>
<pre><code class="language-shell line-numbers">#搜索nessus相关镜像
docker search nessus
#pull nessus最新镜像
docker pull tenableofficial/nessus
#启动docker镜像，同时配置用户名和口令、不启动自动更新
docker run -it -d -p8834:8834 --name nessus -e USERNAME=Nessus -e AUTO_UPDATE=no -e PASSWORD=HDuUNO1XzDEq2Ls tenableofficial/nessus
</code></pre>
<pre><code class="language-shell line-numbers">#进入nessus容器
docker exec -it nessus bash
#启动nessus服务
/opt/scripts/configure_scanner.py

</code></pre>
<h2>访问nessus界面</h2>
<p><strong><code>https://localhost:8834</code></strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg" alt="" /></a></p>
<p><strong>用户名和口令为创建nessus容器时配置的用户名和口令</strong></p>
<pre><code class="language-shell line-numbers">username:Nessus
password:HDuUNO1XzDEq2Ls
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_c582b125111664a9c6b32a7822448b6b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_c582b125111664a9c6b32a7822448b6b.jpg" alt="" /></a></p>
<h1>二、官方注册插件库和激活码</h1>
<p><a class="wp-editor-md-post-content-link" href="https://plugins.nessus.org/v2/offline.php">官网插件库地址</a>：<br />
https://plugins.nessus.org/v2/offline.php</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ada4e589a08b061fb9cc269bc159a4bd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ada4e589a08b061fb9cc269bc159a4bd.jpg" alt="" /></a></p>
<h4>获取第一个值Challenge code</h4>
<pre><code class="language-shell line-numbers">#进入Nessus容器
docker exec -it nessus bash
#生成匹配Challenge code
/opt/nessus/sbin/nessuscli fetch --challenge
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_53f7bd59813c35b6213db9c1f36f484c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_53f7bd59813c35b6213db9c1f36f484c.jpg" alt="" /></a></p>
<p><strong>Challenge code: be86f8bde86494e544d6bad87c2ea9122f8b012d</strong></p>
<h4>获取第二个值激活码Activation Code</h4>
<p>进入<a class="wp-editor-md-post-content-link" href="https://zh-cn.tenable.com/products/nessus/nessus-essentials?tns_redirect=true">官网</a>，邮箱注册获取激活码，填写邮箱接收邮件<br />
https://zh-cn.tenable.com/products/nessus/nessus-essentials?tns_redirect=true</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2e284d8c7dda8752214f442a95eb0fa8.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2e284d8c7dda8752214f442a95eb0fa8.jpg" alt="" /></a></p>
<p>获取激活码</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2dedf9fed1be758a698876ce8209394c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2dedf9fed1be758a698876ce8209394c.jpg" alt="" /></a></p>
<p>提交获取插件下载地址和证书内容</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_57e8f77cc73b6aa8c53aefb92aabfc7a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_57e8f77cc73b6aa8c53aefb92aabfc7a.jpg" alt="" /></a></p>
<p>插件下载地址及激活码License</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_eb3ac519e7b116dbe71dc06b373ea579.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_eb3ac519e7b116dbe71dc06b373ea579.jpg" alt="" /></a></p>
<h2>更新docker中nessus插件库</h2>
<p>将下载的插件库上传至nessus容器中</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_12b65f4dbd5a4c3dc004423e6af78266.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_12b65f4dbd5a4c3dc004423e6af78266.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#从Docker宿主机复制文件到Docker容器 all-2.0.tar.gz插件位置看个人上传宿主机目录
docker cp /data/middleware/nessus/all-2.0.tar.gz nessus:/usr/local/
#Docker容器中更新插件库
docker exec -it nessus /bin/bash
cd /usr/local
#更新插件库
/opt/nessus/sbin/nessuscli update all-2.0.tar.gz
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_78c7f20c643d7823d9d26297908c62a0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_78c7f20c643d7823d9d26297908c62a0.jpg" alt="" /></a></p>
<h2>激活Nessus</h2>
<pre><code class="language-shell line-numbers">#进入容器
docker exec -it nessus /bin/bash
cd /usr/local
#填写刚才所获得的激活码
vi nessus.license

</code></pre>
<pre data-language=XML><code class="language-markup line-numbers">-----BEGIN TENABLE LICENSE-----
aTJZK2tGL1NQY3Fad2UrR0pWeWRobFpxdjJiY1F3d0Q0cEk0OWJtR3FuYjhmOTduOUF1OUMrY0FF
SmRVTkNJUUp5dEN6WTFiY1UrTnlsMG02VEQ0eUZBNU0yVGNDNDA4MmRMZEYyZy9VelhacWYyY3JH
aXFkY29kdnRhUzJtNytBbnJpUnprU21URjQva21kT3VwRWNVYmlHb0QzaXFUekNtZnZITnJaVldx
Wmh1eEFxYU9Pb2cwQW5GZXVRTWFsS1ZOODRBaXBGbFNJWjRrUi9XUUtGYWZZTmY1RGplZjZWVE1F
aUgzUDJnRmxSazJ2WFI4ZVcyazBPVEQ4R3JuTlpIaUZnNVZKdkZqdHJLZ1lYNlBRcU4zTWhIdzZF
Z2ZlajZqaG5QeUpWSkhSVFlTaHcvdzB3OEZUVXRZNU1TZmttRWlpT1lEOHcxejM2STlha1BCSGFB
dERETmFxN3l6SXJ4QTQ3ekRlY3FiS0lLYUhwWUMyeFpPbGNoV3VXZloxNGRvSXRySnFGVXB6MXRP
TERDUkNGQ2lHSHIrYUtjMUM1SUpqWTZKcFRiSHIrZm5wU3k2VDMrY1NzeU1JV3VyUmw1cUNFVWVs
WkJudUxXNkg4R0pwd3gvZEdHYi9TUjNpVjV2dzFoQUpGWG91K2NqM04zTktKVE5VcUp2Zi9URUth
SHNKTy9uWW9ZeXpGck9IUGtzWmxpdVdnMzR6U3V1MGpEamZZYVFsK3Y2ZkRlUHp5dU4vZjhhREdw
MUpSQTN4NGYwUTl3dzg0aXdKd0Zyb0Z1L3ltZE9ValIrbGR2cWFpemp3b0k3cnVCckpiNXlJb0tw
bXR3NDF4OWx5aXFPczM5d056bEkrUlN1UlpRV1BJNDJjUStFN2dwOVA4dUhndzVuZmNXK2RySzA9
DQp7ImFjdGl2YXRpb25fY29kZSI6IkdSQTctMkxVRC1EUENOLTg1WEQtWE1CTSIsInVwZGF0ZV9w
YXNzd29yZCI6ImY4MjM0OTFlYzExYjIxMGI0ODczYTllM2YxMzVlMDE3IiwicGVuZG9fYXBpX2tl
eSI6ImE3YzhkNWM0LWI2YWUtNDg2Ny03ZGFiLTY5YTkyYTA4NDdlMSIsIm5hbWUiOiJOZXNzdXMg
SG9tZSIsInR5cGUiOiJob21lIiwiZXhwaXJhdGlvbl9kYXRlIjoxODE5NTkzMzkwLCJjdXN0b21l
cl9pZCI6MCwiaXBzIjoxNiwidXBkYXRlX2xvZ2luIjoiMDdhOGZhNGZkYmYzNGIxNzU5NGZhNGUw
YTc1NmM2ZTAiLCJkcm0iOiJjMDUyOGZkOWQyNGIyZGQ0MDExMmZjZTNlM2I2NzY1MiJ9
-----END TENABLE LICENSE-----
</code></pre>
<h4>激活</h4>
<pre><code class="language-shell line-numbers">/opt/nessus/sbin/nessuscli fetch --register-offline nessus.license
#重启nessus
/opt/scripts/configure_scanner.py

</code></pre>
<p>等待加载插件库后访问nessus界面</p>
<p><code>https://localhost:8834</code></p>
<pre><code class="language-shell line-numbers">username:Nessus
password:HDuUNO1XzDEq2Ls
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg" alt="" /></a></p>
<p>插件正常加载</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_772a469666fb869bbe65c533211c309e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_772a469666fb869bbe65c533211c309e.jpg" alt="" /></a></p>
<h1>三、Nessus破解修改限制</h1>
<pre><code class="language-shell line-numbers">#nessus初始化完成后Hosts显示为"0 of 16 used”，修改其限制
docker exec -it nessus /bin/bash
#复制插件到容器根目录
cp -r /opt/nessus/lib/nessus/plugins/ /
#查看plugins插件库复制是否成功，若不成功则重新复制
du -h /plugins/
#删除重新复制
rm -rf /plugins
cp -r /opt/nessus/lib/nessus/plugins/ /

</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_f1c564b79bbfc14f7b63e656daab9dcc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_f1c564b79bbfc14f7b63e656daab9dcc.jpg" alt="" /></a></p>
<ul>
<li>查看plugin_feed_info.inc文件位置</li>
</ul>
<pre><code class="language-shell line-numbers">[root@7b287c8f02b0 /]# find / -name "plugin_feed_info.inc"
/opt/nessus/var/nessus/plugin_feed_info.inc
/opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
</code></pre>
<ul>
<li>备份plugin_feed_info.inc</li>
</ul>
<pre><code class="language-shell line-numbers">mkdir /pluginsinc
cp /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc /pluginsinc/plugin_feed_info.inc.libinc
cp /opt/nessus/var/nessus/plugin_feed_info.inc /pluginsinc/plugin_feed_info.inc.varinc
</code></pre>
<ul>
<li>将plugin_feed_info.inc内容修改为专业版，PLUGIN_SET序号号为Policy Template Version=202208301606或其后序号</li>
</ul>
<pre><code class="language-shell line-numbers">vi /pluginsinc/plugin_feed_info.inc
PLUGIN_SET = "202208301606";
PLUGIN_FEED = "ProfessionalFeed (Direct)";
PLUGIN_FEED_TRANSPORT = "Tenable Network Security Lightning";
</code></pre>
<ul>
<li>关闭Nessus服务</li>
</ul>
<pre><code class="language-shell line-numbers">supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
</code></pre>
<ul>
<li>重启Nessus服务</li>
</ul>
<pre><code class="language-shell line-numbers">supervisorctl start nessusd
du -h /opt/nessus/lib/nessus/plugins/
more /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
more /opt/nessus/var/nessus/plugin_feed_info.inc
</code></pre>
<ul>
<li>访问Nessus并更新规则库，此过程特慢需放置等待</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ca43e3cfd0153a5b5649895b972084a2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ca43e3cfd0153a5b5649895b972084a2.jpg" alt="" /></a></p>
<ul>
<li>查看状态</li>
</ul>
<pre><code class="language-shell line-numbers">du -h /opt/nessus/lib/nessus/plugins/
more /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
more /opt/nessus/var/nessus/plugin_feed_info.inc
#若状态异常，重新执行插件删除程序
rm -rf /opt/nessus/lib/nessus/plugins/
cp -r /plugins /opt/nessus/lib/nessus/
supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
supervisorctl start nessusd
</code></pre>
<h4>重置启动</h4>
<p>因服务重启时unlimited失效，根据状态异常操作步骤重新操作，编写nessus_start.sh代替service nessusd start，因为命令执行过程较长且Nessus需要重新加载插件，启动过程慢是正常现象。</p>
<pre><code class="language-shell line-numbers">vi /root/nessus_start.sh

#!/bin/bash
rm -rf /opt/nessus/lib/nessus/plugins/
cp -r /plugins /opt/nessus/lib/nessus/
supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
supervisorctl start nessusd

chmod +x /root/nessus_start.sh
</code></pre>
<p>手动执行脚本</p>
<pre><code class="language-shell line-numbers">/root/nessus_start.sh
</code></pre>
<p><a href="https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/">CentOS Docker环境部署Nessus漏洞扫描 系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Linux系统网络安全检查方案汇总记录</title>
		<link>https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Fri, 22 Jul 2022 09:27:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[网络安全]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=244</guid>

					<description><![CDATA[<p>记录一下日常可能用到的系统检测方案及命令 1. 服务器是否被暴力破解 Debian 和 Ubuntu &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/">Linux系统网络安全检查方案汇总记录</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>记录一下日常可能用到的系统检测方案及命令</em></p>
<h5>1.  服务器是否被暴力破解</h5>
<pre><code class="language-shell line-numbers">Debian 和 Ubuntu 存储在 /var/log/auth.log
RedHat 和 CentOS 存储在 /var/log/secure

1.查看 root 用户登录成功的IP及次数看看是否有不熟悉的 IP 地址

grep "Accepted password for root" /var/log/secure | awk '{print <span class="katex math inline">11}' | sort | uniq -c | sort -nr | more

2.查看尝试暴力破解 root 账户的IP及次数
 grep "Failed password for root" /var/log/secure | awk '{print</span>11}' | sort | uniq -c | sort -nr | more

3.查看尝试暴力破解用户名的IP及次数
grep "Failed password for invalid user" /var/log/secure | awk '{print $13}' | sort | uniq -c | sort -nr | more
</code></pre>
<h5>2.  隐藏系统信息</h5>
<p>默认情况下，登录提示信息包括Linux发行版的名称、版本、内核版本和主机名等信息，这些信息对于黑客入侵是很有帮助的，因此，出于服务器的安全考虑，需要将这些信息修改或注释掉。应该只显示一个“login:”提示符。<br />
操作时删除 <code>/etc/issue和/etc/issue.net</code> 文件中的内容即可。</p>
<pre><code class="language-shell line-numbers">[root@localhost ~]# vim  /etc/issue   issue文件是用户从本地登录时看到的提示(注释或删除内容)

[root@localhost ~]# vim  /etc/issue.net   issue.net文件是用户从网络登录（如telnet、ssh）系统时看到的登录提示(注释或删除内容)。

</code></pre>
<h5>3.  禁ping设置</h5>
<p>在 <code>/etc/rc.d/rc.local</code> 文件增加：<code>echo 1 &gt; /proc/sys/net/ipv4/icmp_echo_ignore_all</code> ，防止别人ping自己的系统，从而增加系统的安全性。</p>
<pre><code class="language-shell line-numbers">echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
</code></pre>
<h5>4.  防止IP欺骗</h5>
<p>在 <code>/etc/host.conf</code> 文件增加一行：<code>nospoof on</code>，防止IP欺骗。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_f94e94c7b8dce4fe34952100dc97e7db.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_f94e94c7b8dce4fe34952100dc97e7db.jpg" alt="" /></a></p>
<h5>5.  使用以下命令对系统进行系统安全检查。</h5>
<pre><code class="language-shell line-numbers"># Whoami           当前用户？
# W                所有登录用户包括网络登录的？
# Who              所有登录用户包括网络登录的？
# history          历史命令记录
# clear            清屏
# last             曾经登录的用户
# top              活动进程
# netstat          查看网络状态

</code></pre>
<h5>6. 定期检查系统中的日志</h5>
<p>（1）<code>/var/log/messages</code> 日志文件。检查 <code>/var/log/messages</code> 日志文件，查看外部用户的登录情况。</p>
<p>（2）history文件。检查用户主目录 <code>/home/username</code> 下的历史文件，即 <code>.history</code> 文件。</p>
<h5>7. 分区保护</h5>
<p>在Linux系统中，可以将不同的应用安装在不同的分区上，每个分区分别进行不同的配置，可以将关键分区设置为只读，这样可以大大提高Linux文件系统的安全。Linux文件系统可以分为几个主要的分区，一般情况下至少需要建立 <code>/boot、/lib、/sbin、/usr/local、/var和/home</code> 等分区。</p>
<p><code>/usr</code> 可以安装成只读，并且可以被认为是不可修改的，如果 <code>/usr</code> 中有任何文件发生了改变，那么系统将立即发出安全报警。</p>
<p><code>/boot、/lib和/sbin</code> 的安装和设置也一样，在安装时尽量将它们设为只读。<br />
不过有些分区是不能设为只读的，比如 <code>/var</code>。</p>
<pre><code class="language-shell line-numbers">[root@localhost /]# chattr +i  /usr 加i属性使得root用户也不能在/BIN 创建改变文件

[root@localhost /]# lsattr -d  /usr 验证i属性加成功否？
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2fbb72e741e89b20c8d7a98bc23280a0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2fbb72e741e89b20c8d7a98bc23280a0.jpg" alt="" /></a></p>
<h5>8. 用户管理</h5>
<pre><code class="language-shell line-numbers">查看用户列表：cat /etc/passwd
查看组列表：cat /etc/group

userdel sync
userdel shutdown
# 需要删除的多余用户共有：sync shutdown halt uucp operator games gopher
groupdel adm
groupdel games
# 需要删除的多余用户组共有：adm lp games dip
</code></pre>
<p>Linux中的帐号和口令是依据 /etc/passwd 、/etc/shadow、 /etc/group 、/etc/gshadow 这四个文档的，所以需要更改其权限提高安全性：</p>
<pre><code class="language-shell line-numbers">chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshado
</code></pre>
<p>如果还原，<strong>把 +i 改成 -i</strong> ,再执行一下上面四条命令。</p>
<p><strong>注：i属性：不允许对这个文件进行修改，删除或重命名，设定连结也无法写入或新增数据！只有 root 才能设定这个属性。</strong></p>
<h5>9. 查看当前网络通信IP</h5>
<pre><code class="language-shell line-numbers">#当前网络IP及请求连接数

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

#当前80端口通信IP，排查是否CC攻击

netstat -an|grep ':80' -c

#端口抓包分析
tcpdump -nn port 80 or port 443

</code></pre>
<h5>10. CentOS7防⽕墙放⾏或限制指定IP和端⼝（firewall）</h5>
<pre><code class="language-shell line-numbers">CentOS7默认没有安装iptables，可以⼿动安装iptables；也可以通过CentOS7已带的firewall配置防⽕墙。
1.查看firewalld.service服务状态
systemctl status firewalld

2.查看firewall运⾏状态
firewall-cmd --state

3.⼿动启动/停⽌/重启firewalld.service服务
# 启动firewalld
service firewalld start
# 停⽌firewalld
service firewalld stop
# 重启firewalld
service firewalld restart

4.展⽰当前配置的firewall规则
firewall-cmd --list-all

5.端⼝（端⼝段）的查询/开放
# 查询端⼝是否开放
firewall-cmd --query-port=8080/tcp
# 新建永久规则，开放8080端⼝（TCP协议）
firewall-cmd --permanent --add-port=8080/tcp
# 移除上述规则
firewall-cmd --permanent --remove-port=8080/tcp
# 新建永久规则，批量开放⼀段端⼝（TCP协议）
firewall-cmd --permanent --add-port=9001-9100/tcp

6.IP（IP段）的开放
# 新建永久规则，开放192.168.1.1单个源IP的访问
firewall-cmd --permanent --add-source=192.168.1.1
# 新建永久规则，开放192.168.1.0/24整个源IP段的访问
firewall-cmd --permanent --add-source=192.168.1.0/24
# 移除上述规则
firewall-cmd --permanent --remove-source=192.168.1.1

7.系统服务的开放
# 开放http服务
firewall-cmd --permanent --add-service=http
# 移除上述规则
firewall-cmd --permanent --remove-service=http

8.⾃定义复杂规则（注意是否与已有规则冲突）
# 允许指定IP访问本机8080端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.1" port protocol="tcp" port="8080" accept'

# 允许指定IP段访问本机8080-8090端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="8080-8090" accept'

# 禁⽌指定IP访问本机8080端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.1" port protocol="tcp" port="8080" reject'

9.任何修改操作，配置完成后，需要重新装载firewall。可重新启动firewalld服务。
firewall-cmd --reload
service firewalld restart
</code></pre>
<p>持续更新&#8230;..</p>
<p><a href="https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/">Linux系统网络安全检查方案汇总记录</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7.9安装Nodejs爬坑</title>
		<link>https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 19 Jul 2022 07:02:15 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[npm]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=238</guid>

					<description><![CDATA[<p>引用博文 前言：在安装Nodejs过程中出现了如下报错 node: relocation error &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/">CentOS7.9安装Nodejs爬坑</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><a class="wp-editor-md-post-content-link" href="https://www.jianshu.com/p/990a093e9e1d?u_atoken=c9da25e6-e1a0-474a-8f75-7b59306bc804&#038;u_asession=01xpruQfmpwzKf05qj9yoM__R1IbJ1flBDVWVw5kWNhDYzWWnvk0PXjbN8ZJf0Hcd4X0KNBwm7Lovlpxjd_P_q4JsKWYrT3W_NKPr8w6oU7K9oXnVffIuJgR38HvyHdZ5lPpcarp92QKzyJKyYjREPlmBkFo3NEHBv0PZUm6pbxQU&#038;u_asig=05ReNMps794XZLa2116BvqUbqDZRKP9BxA0TKKMDGuUvcz-jm-bt9qct8mQ75BKIuBnWqBdZoR6bfDE76CL4sAi0SY3k-konqsqzun1p2m36FkaC7PWoG3eQjXiVMlUzZv0c3YB6hOBdchQ0YEkR0IXQ-oMoNm16aE933hN47KEAr9JS7q8ZD7Xtz2Ly-b0kmuyAKRFSVJkkdwVUnyHAIJzcMTDxdrEpkmF-Oh34m5Dc41MqkdD2Eu1Ij6iItBcYzCWPRPQyB_SKrj-61LB_f61u3h9VXwMyh6PgyDIVSG1W8IN89uV4tqg0ewrf7Gv3TDXsc5ggf623lX74vpg8_18VOzw7_0TmEGwkZ8XryrdyrvMMJF8I4XcLixaby12wqSmWspDxyAEEo4kbsryBKb9Q&#038;u_aref=HWFn0mHZBymIuPLmHken%2F8KbQms%3D">引用博文</a></p>
<p><em>前言：在安装Nodejs过程中出现了如下报错</em></p>
<pre><code class="language-shell line-numbers">node: relocation error: /lib64/libnode.so.93: symbol FIPS_selftest, version OPENSSL_1_1_0g not defined in file libcrypto.so.1.1 with link time reference
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_36af827772014031e2aa245079c6ee76.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_36af827772014031e2aa245079c6ee76.jpg" alt="" /></a></p>
<p>在升级了Openssl，Openssh无果之后，在百度/Google检索，很少有见到这类问题的解决办法，只能尝试上文中提到的降级方式，刚好我的服务器也是<strong>glibc2.17</strong>版本。</p>
<p><code>ldd --version</code></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8fe256df50092f4d761bd06fe5a241bd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8fe256df50092f4d761bd06fe5a241bd.jpg" alt="" /></a></p>
<h1>安装</h1>
<p><a class="wp-editor-md-post-content-link" href="https://nodejs.org/en/about/previous-releases">下载历史NodeJs版本</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_d95d1b19675aced5767a5b4edc971cac.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_d95d1b19675aced5767a5b4edc971cac.jpg" alt="" /></a></p>
<p>安装配置NodeJs</p>
<pre><code class="language-shell line-numbers">yum install gcc gcc-c++

tar -xvf node-v12.19.1-linux-x64.tar.gz

mv node-v12.19.1-linux-x64 node

#配置环境变量
vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=<span class="katex math inline">NODE_HOME/bin:</span>PATH
source /etc/profile

</code></pre>
<h1>验证</h1>
<pre><code class="language-shell line-numbers">node -v
npm -v
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_bc32bc428c87c774e0bf8e0d8da9dc3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_bc32bc428c87c774e0bf8e0d8da9dc3a.jpg" alt="" /></a></p>
<p><em>ps:记录一次爬坑,升级openssh/l可以看以往博文<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS 7 离线更新升级 openSSH 9.8p1</a></em></p>
<p><a href="https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/">CentOS7.9安装Nodejs爬坑</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
