<?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>System Setting (系统设置) &#8211; Eternal Center</title>
	<atom:link href="https://eternalcenter-sep-2022.github.io/category/system/system-operation-system-setting-system-software/system-setting/feed/" rel="self" type="application/rss+xml" />
	<link>https://eternalcenter-sep-2022.github.io/</link>
	<description></description>
	<lastBuildDate>Fri, 09 Sep 2022 09:42:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>[内容] Linux 密码文件 /etc/shadow 的介绍 （显示用户密码相关的策略）</title>
		<link>https://eternalcenter-sep-2022.github.io/etc-shadow/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 09:40:25 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=28282</guid>

					<description><![CDATA[内容一：/etc/shadow 文件的简介 1) /etc/shadow 文件存储着用户的密码和与之相关的信息2) /etc/shadow 文件以冒号 “:” 作为分隔符，分类 8 段 内容二：/etc/shadow 文件的作用 2.1 第 1 段内容：用户名 /etc/shadow 文件的第 1 段存储的是用户名，和 /etc/passwd 文件中的用户名是一一对应的 2.2 第 2 段内容：密码 2.2.1 内容的含义 1) 如果是奇怪的字符串则代表是加密过的密码，格式是 $id$salt$hashed，其中 $id 是指加密算法。如果字符串：以 $1$ 开头则代表是用 MD5 加密，以 $2a$ 开头则代表是用 Blowfish 加密，以 $2y$ 开头则代表是用另一种算法长度的 Blowfish 加密，以 $5$ 开头则代表是用 SHA-256 加密，以 $6$ 开头则代表是用 SHA-512 加密2) 如果是 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/etc-shadow/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux 密码文件 /etc/shadow 的介绍 （显示用户密码相关的策略）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：/etc/shadow 文件的简介</h3>



<p>1) /etc/shadow 文件存储着用户的密码和与之相关的信息<br>2) /etc/shadow 文件以冒号 “:” 作为分隔符，分类 8 段</p>



<h3>内容二：/etc/shadow 文件的作用</h3>



<h4>2.1 第 1 段内容：用户名</h4>



<p>/etc/shadow 文件的第 1 段存储的是用户名，和 /etc/passwd 文件中的用户名是一一对应的</p>



<h4>2.2 第 2 段内容：密码</h4>



<h5>2.2.1 内容的含义</h5>



<p>1) 如果是奇怪的字符串则代表是加密过的密码，格式是 $id$salt$hashed，其中 $id 是指加密算法。如果字符串：以 $1$ 开头则代表是用 MD5 加密，以 $2a$ 开头则代表是用 Blowfish 加密，以 $2y$ 开头则代表是用另一种算法长度的 Blowfish 加密，以 $5$ 开头则代表是用 SHA-256 加密，以 $6$ 开头则代表是用 SHA-512 加密<br>2) 如果是 2 个感叹号 “!!” 则代表从来都没有设置过密码<br>3) 如果为空则代表没有设置密码<br>4) 如果是 1 个星号 “*” 则代表用户被锁定，但是其它登陆方式不受限制，例 SSH 登陆<br>5) 如果是 1 个感叹号 “!” 则代表用户被锁定，但是其它登陆方式不受限制，例 SSH 登陆<br>6) 如果以 1 个感叹号开头 “!” 则代表用户被锁定<br>7) 如果以 2 个感叹号开头 “!!” 则代表用户被锁定</p>



<h5>2.2.2 查看命令</h5>



<pre class="wp-block-code"><code># cut -d: -f1,7</code></pre>



<h5>2.2.3 修改命令</h5>



<pre class="wp-block-code"><code># passwd &lt;user&gt;</code></pre>



<h4>2.3 第 3 段内容：密码最后的修改日期</h4>



<h5>2.3.1 内容的含义</h5>



<p>密码最后修改的日期于 1970 年 1 月 1 日相距的天数</p>



<h5>2.3.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,3</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Last password change'</code></pre>



<h5>2.3.3 修改命令</h5>



<pre class="wp-block-code"><code># chage -d &lt;date&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --lastday &lt;date&gt; &lt;user&gt;</code></pre>



<h4>2.4 第 4 段内容：修改密码最短天数间隔</h4>



<h5>2.4.1 内容的含义</h5>



<p>两次修改密码最短天数间隔</p>



<p>1) 如果是 0 则代表随时可以修改密码<br>2) 如果是 99999 则代表永远都不能修改密码</p>



<h5>2.4.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,4</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Minimum number of days between password change'</code></pre>



<h5>2.4.3 修改命令</h5>



<pre class="wp-block-code"><code># chage -m &lt;days&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --mindays &lt;days&gt; &lt;user&gt;</code></pre>



<h4>2.5 第 5 段内容：密码过期的天数</h4>



<h5>2.5.1 内容的含义</h5>



<p>修改密码后过多少天会过期</p>



<p>1) 如果是 99999 则代表永远都不会过期<br>2) 如果密码只是过期但是没有失效的话，则可以使用过期的密码更改密码再使用新密码登陆，如果密码失效的话则此密码不能再使用</p>



<h5>2.5.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,5</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Maximum number of days between password change'</code></pre>



<h5>2.5.3 修改命令</h5>



<pre class="wp-block-code"><code># chage -M &lt;days&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --maxdays &lt;days&gt; &lt;user&gt;</code></pre>



<h4>2.6 第 6 段内容：密码过期前提前多少天发出警告</h4>



<h5>2.6.1 内容的含义</h5>



<p>密码过期前，提前多少天发出警告</p>



<p>如果为空则代表不发出警告</p>



<h5>2.6.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,6</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Number of days of warning before password expires'</code></pre>



<h5>2.6.3 修改密码</h5>



<pre class="wp-block-code"><code># chage -W &lt;days&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --warndays &lt;days&gt; &lt;user&gt;</code></pre>



<h4>2.7 第 7 段内容：密码失效的天数</h4>



<h5>2.7.1 内容的含义</h5>



<p>密码过期后过多少天会失效</p>



<p>1) 如果是 99999 则代表永远都不会失效<br>2) 如果密码只是过期但是没有失效的话，则可以使用过期的密码更改密码再使用新密码登陆，如果密码失效的话则此密码不能再使用</p>



<h5>2.7.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,7</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Password inactive'</code></pre>



<h5>2.7.3 修改密码</h5>



<pre class="wp-block-code"><code># chage -I &lt;days&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --inactive &lt;days&gt; &lt;user&gt;</code></pre>



<h4>2.8 第 8 段内容：用户的失效日期</h4>



<h5>2.8.1 内容的含义</h5>



<p>用户的失效日期于 1970 年 1 月 1 日相距的天数</p>



<h5>2.8.2 查看命令</h5>



<pre class="wp-block-code"><code># egrep ^&#91;^:]+:&#91;^\!*] /etc/shadow | cut -d: -f1,8</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage -l &lt;user&gt; | grep 'Account expires'</code></pre>



<h5>2.8.3 修改密码</h5>



<pre class="wp-block-code"><code># chage -E &lt;date&gt; &lt;user&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># chage --expiredate &lt;date&gt; &lt;user&gt;</code></pre>



<h4>2.9 第 9 段内容：保留</h4>



<p>这是一个保留位，目前没有作用</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] Linux 解决执行 service crond status 命令时，报错 “crond dead but pid file exists”</title>
		<link>https://eternalcenter-sep-2022.github.io/debug-crond-dead-but-pid-file-exists/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 07 Sep 2022 13:28:06 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=28199</guid>

					<description><![CDATA[报错代码： 解决方法： 步骤一：找到 crond.pid 文件 步骤二：删除 crond.pid 文件]]></description>
										<content:encoded><![CDATA[
<h2>报错代码：</h2>



<pre class="wp-block-code"><code>crond dead but pid file exists</code></pre>



<h2>解决方法：</h2>



<h3>步骤一：找到 crond.pid 文件</h3>



<pre class="wp-block-code"><code># find / -name cron*
/spool/anacron/cron.daily
/spool/anacron/cron.weekly
/spool/anacron/cron.monthly
/spool/cron
/lock/subsys/crond
/run/cron.reboot
/run/crond.pid</code></pre>



<h3>步骤二：删除 crond.pid 文件</h3>



<pre class="wp-block-code"><code># rm -rf crond.pid</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] openSUSE &#038; SUSE 解决执行 systemctl enable 命令或者 systemd-sysv-install enable 命令时报错 “&#8230;..: No such file or directory”</title>
		<link>https://eternalcenter-sep-2022.github.io/no-such-file-or-directory/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 03:08:13 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Software (系统软件)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27547</guid>

					<description><![CDATA[报错代码 解决方法]]></description>
										<content:encoded><![CDATA[
<h2>报错代码</h2>



<pre class="wp-block-code"><code>......: No such file or directory</code></pre>



<h2>解决方法</h2>



<pre class="wp-block-code"><code># zypper in insserv-compat</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] /etc/resolv.conf 配置文件的 search 选项</title>
		<link>https://eternalcenter-sep-2022.github.io/etc-resolv-conf-search/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 10 Aug 2022 15:07:19 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Other Service (其它服务)]]></category>
		<category><![CDATA[Service (服务)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27527</guid>

					<description><![CDATA[内容一：测试 search 选项的配置 内容二：测试 search 选项 2.1 查询 zhumingyu （补充：当查询 zhumingyu 时，也就是中间没有点 “.”，则默认会被视为查询主机名，会先依次把 eternalcenter.com、local 和 new 作为后缀添加到 zhumingyu 后进行查询，最后才查询 zhumingyu） 2.2 zhumingyu.com （补充：当查询 zhumingyu.com 时，也就是中间有 1 个点 “.”，则默认会被视为查询域名，会先查询 mingyuzhu.com，如果查询失败，则会先依次把 eternalcenter.com、local 和 new 作为后缀添加到 zhumingyu 后进行查询） 2.3 查询 zhumingyu.com. （补充：当查询 zhumingyu.com. 时，也就是末尾有 1 个点 “.”，默认会被视为查询域名，且只会查询这个域名。不会查询 search 里的每 1 项）]]></description>
										<content:encoded><![CDATA[
<h3>内容一：测试 search 选项的配置</h3>



<pre class="wp-block-code"><code># cat /etc/resolv.conf
search eternalcenter.com local new
nameserver 8.8.8.8</code></pre>



<h3>内容二：测试 search 选项</h3>



<h4>2.1 查询 zhumingyu</h4>



<pre class="wp-block-code"><code># host -a zhumingyu
Trying "zhumingyu.eternalcenter.com"
Trying "zhumingyu.local"
Trying "zhumingyu.new"
Trying "zhumingyu"
Host zhumingyu not found: 3(NXDOMAIN)
Received 102 bytes from 8.8.8.8#53 in 62 ms</code></pre>



<p>（补充：当查询 zhumingyu 时，也就是中间没有点 “.”，则默认会被视为查询主机名，会先依次把 eternalcenter.com、local 和 new 作为后缀添加到 zhumingyu 后进行查询，最后才查询 zhumingyu）</p>



<h4>2.2 zhumingyu.com</h4>



<pre class="wp-block-code"><code># host -a zhumingyu.com
Trying "zhumingyu.com"
Received 31 bytes from 1.1.1.1#53 in 217 ms
Trying "zhumingyu.com.eternalcenter.com"
Trying "zhumingyu.com.local"
Trying "zhumingyu.com.new"
Host zhumingyu.com.new not found: 4(NOTIMP)
Received 35 bytes from 1.1.1.1#53 in 218 ms</code></pre>



<p>（补充：当查询 zhumingyu.com 时，也就是中间有 1 个点 “.”，则默认会被视为查询域名，会先查询 mingyuzhu.com，如果查询失败，则会先依次把 eternalcenter.com、local 和 new 作为后缀添加到 zhumingyu 后进行查询）</p>



<h4>2.3 查询 zhumingyu.com.</h4>



<pre class="wp-block-code"><code># host -a zhumingyu.com.
Trying "zhumingyu.com"
Host zhumingyu.com not found: 4(NOTIMP)
Received 31 bytes from 1.1.1.1#53 in 204 ms
Received 31 bytes from 1.1.1.1#53 in 204 ms</code></pre>



<p>（补充：当查询 zhumingyu.com. 时，也就是末尾有 1 个点 “.”，默认会被视为查询域名，且只会查询这个域名。不会查询 search 里的每 1 项）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 modprobe、rmmod、insmod、lsmod、modinfo 的使用 （管理模块）</title>
		<link>https://eternalcenter-sep-2022.github.io/modprobe-rmmod-insmod-lsmod-modinfo/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 01 Aug 2022 06:10:32 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Software (系统软件)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27461</guid>

					<description><![CDATA[内容一：modprobe 命令的选项 1) -a 或者 &#8211;all，载入所有模块2) -c 或者 &#8211;show-conf 显示所有模块的配置信息3) -r 或者 &#8211;remove 卸载模块，必须在模块闲置不用时操作。4) -v 或者 &#8211;verbose 显示执行时的详细信息5) -V 或者 &#8211;version 显示命令的版本信息6) -h 或者 &#8211;help 显示命令的帮助信息 内容二：modprobe、insmod、rmmod、lsmod、modinfo 命令的案例 2.1 案例一：安装模块 或者： 2.2 案例二：删除模块 或者： 2.3 案例三：显示所有模块 2.4 案例四：显示某 1 个模块的详细信息]]></description>
										<content:encoded><![CDATA[
<h3>内容一：modprobe 命令的选项</h3>



<p>1) -a 或者 &#8211;all，载入所有模块<br>2) -c 或者 &#8211;show-conf 显示所有模块的配置信息<br>3) -r 或者 &#8211;remove 卸载模块，必须在模块闲置不用时操作。<br>4) -v 或者 &#8211;verbose 显示执行时的详细信息<br>5) -V 或者 &#8211;version 显示命令的版本信息<br>6) -h 或者 &#8211;help 显示命令的帮助信息</p>



<h3>内容二：modprobe、insmod、rmmod、lsmod、modinfo 命令的案例</h3>



<h4>2.1 案例一：安装模块</h4>



<pre class="wp-block-code"><code># modprobe floppy</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># insmod floppy</code></pre>



<h4>2.2 案例二：删除模块</h4>



<pre class="wp-block-code"><code># modprobe -r floppy</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># rmmod floppy</code></pre>



<h4>2.3 案例三：显示所有模块</h4>



<pre class="wp-block-code"><code># lsmod</code></pre>



<h4>2.4 案例四：显示某 1 个模块的详细信息</h4>



<pre class="wp-block-code"><code># modinfo floppy</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 文件 profile 和 bashrc （用户登录环境的设置）</title>
		<link>https://eternalcenter-sep-2022.github.io/profile-bashrc/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 29 Jul 2022 06:43:12 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27441</guid>

					<description><![CDATA[内容一：profile 文件 1.1 profile 全局文件的位置 （影响所有用户） 1.2 profile 局部文件的位置 （只影响单个用户） 或者： 或者： 1.3 profile 文件的作用 在用户登录时设置用户的环境变量，只在用户登录时才会生效 1.4 登录 Linux 时执行 profile 文件的顺序 第一步，执行： 第二步，按以下顺序一一尝试执行以下 3 个文件中的 1 个，当执行成功后则停止尝试下 1 个文件： 第三步：开始调用解释器 （如果是调用 bash 解释器，则继续执行登录 bash 时执行 bashrc 文件的顺序） 内容二：bashrc 文件 2.1 bashrc 全局文件的位置 （影响所有用户） 或者： 2.2 bashrc 局部文件的位置 （只影响单个用户） 2.3 bashrc 文件的作用 在用户使用 bash 解释器或登录 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/profile-bashrc/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux 文件 profile 和 bashrc （用户登录环境的设置）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：profile 文件</h3>



<h4>1.1 profile 全局文件的位置 （影响所有用户）</h4>



<pre class="wp-block-code"><code>/etc/profile</code></pre>



<h4>1.2 profile 局部文件的位置 （只影响单个用户）</h4>



<pre class="wp-block-code"><code>~/.bash_profile</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>~/.bash_login</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>~/.profile</code></pre>



<h4>1.3 profile 文件的作用</h4>



<p>在用户登录时设置用户的环境变量，只在用户登录时才会生效</p>



<h4>1.4 登录 Linux 时执行 profile 文件的顺序</h4>



<p>第一步，执行：</p>



<pre class="wp-block-code"><code>/etc/profile</code></pre>



<p>第二步，按以下顺序一一尝试执行以下 3 个文件中的 1 个，当执行成功后则停止尝试下 1 个文件：</p>



<pre class="wp-block-code"><code>~/.bash_profile
~/.bash_login
~/.profile</code></pre>



<p>第三步：开始调用解释器</p>



<p>（如果是调用 bash 解释器，则继续执行登录 bash 时执行 bashrc 文件的顺序）</p>



<h3>内容二：bashrc 文件</h3>



<h4>2.1 bashrc 全局文件的位置 （影响所有用户）</h4>



<pre class="wp-block-code"><code>/etc/bashrc</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>/etc/bash.bashrc</code></pre>



<h4>2.2 bashrc 局部文件的位置 （只影响单个用户）</h4>



<pre class="wp-block-code"><code>~/.bashrc</code></pre>



<h4>2.3 bashrc 文件的作用</h4>



<p>在用户使用 bash 解释器或登录 bash 解释器时设置用户的环境变量，每次调用 bash 解释器时都会生效</p>



<h4>2.4 使用 bash 或登录 bash 时执行 bashrc 文件的顺序</h4>



<p>第一步，执行以下 2 个文件中的 1 个：</p>



<pre class="wp-block-code"><code>/etc/bashrc
/etc/bash.bashrc</code></pre>



<p>第二步，执行：</p>



<pre class="wp-block-code"><code>~/.bashrc</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 su （切换用户）</title>
		<link>https://eternalcenter-sep-2022.github.io/su/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 25 Jul 2022 08:33:37 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27201</guid>

					<description><![CDATA[案例一：切换用户，切换后保持当前用户所在的目录，并使用当前用户的环境变量 案例二：切换用户，切换后进入被切换用户的家目录，并使用被切换用户的环境变量]]></description>
										<content:encoded><![CDATA[
<h3>案例一：切换用户，切换后保持当前用户所在的目录，并使用当前用户的环境变量</h3>



<pre class="wp-block-code"><code># su &lt;user&gt;</code></pre>



<h3>案例二：切换用户，切换后进入被切换用户的家目录，并使用被切换用户的环境变量</h3>



<pre class="wp-block-code"><code># su - &lt;user&gt;</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] audit 的设置 （日志保存时间）</title>
		<link>https://eternalcenter-sep-2022.github.io/audit-log-save-time/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 18 Jul 2022 01:45:08 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Service (服务)]]></category>
		<category><![CDATA[SFTP]]></category>
		<category><![CDATA[Storage Service (存储服务)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System General Log (系统普通日志)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26972</guid>

					<description><![CDATA[方法一：通过 audit 配置文件设置 1.1 设置 audit 日志的保存时间 确保部分内容如下： （补充：这里以1) 开启 audit 日志 （local_events = yes） （write_logs = yes）2) 将 audit 日志写入 /var/log/audit/audit.log 文件 （log_file = /var/log/audit/audit.log）3) audit 日志每达到 8M 大小就将旧的 audit 日志进行备份并创建新的 audit 日志 （max_log_file = 8） （max_log_file_action = ROTATE），也可以修改成： max_log_file_action = keep_logs4) 旧的 audit 日志保存 5 份 （num_logs =5）为例） 1.2 让设置的 audit 时间生效 方法二：通过 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/audit-log-save-time/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] audit 的设置 （日志保存时间）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>方法一：通过 audit 配置文件设置</h3>



<h4>1.1 设置 audit 日志的保存时间</h4>



<pre class="wp-block-code"><code># vim /etc/audit/auditd.conf</code></pre>



<p>确保部分内容如下：</p>



<pre class="wp-block-code"><code>......
local_events = yes
......
write_logs = yes
......
log_file = /var/log/audit/audit.log
......
max_log_file = 8
......
num_logs =5
......
max_log_file_action = ROTATE
......</code></pre>



<p>（<br>补充：这里以<br>1) 开启 audit 日志 （local_events = yes） （write_logs = yes）<br>2) 将 audit 日志写入 /var/log/audit/audit.log 文件 （log_file = /var/log/audit/audit.log）<br>3) audit 日志每达到 8M 大小就将旧的 audit 日志进行备份并创建新的 audit 日志 （max_log_file = 8） （max_log_file_action = ROTATE），也可以修改成： max_log_file_action = keep_logs<br>4) 旧的 audit 日志保存 5 份 （num_logs =5）<br>为例<br>）</p>



<h4>1.2 让设置的 audit 时间生效</h4>



<pre class="wp-block-code"><code># service auditd restart</code></pre>



<h3>方法二：通过 logrotate 配置文件设置</h3>



<h4>2.1 设置 audit 日志的保存时间</h4>



<pre class="wp-block-code"><code># vim /etc/logrotate.d/auditd</code></pre>



<p>创建以下内容：</p>



<pre class="wp-block-code"><code>/var/log/audit/*
{
rotate 30
daily
missingok
compress
delaycompress
postrotate
touch /var/log/audit/audit.log ||:
chmod 0600 /var/log/audit/audit.log ||:
service auditd restart
endscript
}</code></pre>



<p>（<br>补充：这里以：<br>1) 备份的日志文件保留 30 份 （rotate 30）<br>2) 每天将现在的日志文件进行备份并生成新的日志文件 （dayly）<br>）</p>



<h4>2.2 让设置的 audit 时间生效</h4>



<pre class="wp-block-code"><code># systemctl restart logrotate.service</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 非 root 用户 ping 命令使用的禁止和允许</title>
		<link>https://eternalcenter-sep-2022.github.io/non-root-user-ping-diable-enable/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 15 Jul 2022 07:00:36 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26794</guid>

					<description><![CDATA[步骤一：禁止非 root 用户使用 ping 步骤二：允许非 root 用户使用 ping 补充：当禁止禁止非 root 用户使用 ping 时，非 root 用户使用 ping 命令的报错 如果是 Rocky Linux &#38; RHEL： 如果是 openSUSE &#38; SLE：]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：禁止非 root 用户使用 ping</h3>



<pre class="wp-block-code"><code>#  sysctl net.ipv4.ping_group_range="1 0"</code></pre>



<h3>步骤二：允许非 root 用户使用 ping</h3>



<pre class="wp-block-code"><code># sysctl net.ipv4.ping_group_range="0 2147483647"</code></pre>



<h3>补充：当禁止禁止非 root 用户使用 ping 时，非 root 用户使用 ping 命令的报错</h3>



<p>如果是 Rocky Linux &amp; RHEL：</p>



<pre class="wp-block-code"><code>ping: socket: Address family not supported by protocol</code></pre>



<p>如果是 openSUSE &amp; SLE：</p>



<pre class="wp-block-code"><code>Error: ping: socket: Operation not permitted</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] audit 日志时间格式的转换</title>
		<link>https://eternalcenter-sep-2022.github.io/time-format-conversion/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Thu, 07 Jul 2022 08:00:02 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Service (服务)]]></category>
		<category><![CDATA[SFTP]]></category>
		<category><![CDATA[Storage Service (存储服务)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System General Log (系统普通日志)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26438</guid>

					<description><![CDATA[步骤一：创建用于 audit 转换日志时间格式的脚本 创建以下内容： （补充：这里以创建名为 time_format_conversion.pl 的用于转换 audit 日志时间格式的脚本为例） 步骤二：转换 audit 日志时间格式 或者： 或者： 或者： 或者： 或者： （补充：这里以使用名为 time_format_conversion.pl 的用于转换 audit 日志时间格式的脚本为例）]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：创建用于 audit 转换日志时间格式的脚本</h3>



<pre class="wp-block-code"><code># vim time_format_conversion.pl</code></pre>



<p>创建以下内容：</p>



<pre class="wp-block-code"><code>s/(1\d{9})/localtime($1)/e</code></pre>



<p>（补充：这里以创建名为 time_format_conversion.pl 的用于转换 audit 日志时间格式的脚本为例）</p>



<h3>步骤二：转换 audit 日志时间格式</h3>



<pre class="wp-block-code"><code># cat /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># less /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># more /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># head /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># tail /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># tail -f /var/log/audit/audit.log | perl -p time_format_conversion.pl</code></pre>



<p>（补充：这里以使用名为 time_format_conversion.pl 的用于转换 audit 日志时间格式的脚本为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] 文件或目录的监控 （audit 版）</title>
		<link>https://eternalcenter-sep-2022.github.io/monitor-directory-file-audit/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 05 Jul 2022 10:18:15 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System General Log (系统普通日志)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26264</guid>

					<description><![CDATA[步骤一：使用 audit 监控文件或目录 1.1 在 audit 的策略里添加要监控的目录或文件 1.1.1 案例一：监控某个目录以及目录下的目录和文件 添加以下内容： （补充：这里以监控目录 /tmp 里的目录和文件为例） 1.1.2 案例二：监控某个文件 添加以下内容： （补充：这里以监控目录 /dev/null 文件为例） 1.2 让监控目录或文件的配置生效 步骤二：显示 audit 监控记录 （补充：记录里的1) nametype=CREATE 字段代表创建2) nametype=NORMAL 字段代表普通3) nametype=DELETE 字段代表删除） 或者： （补充：这里以显示文件被修改的记录为例）]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：使用 audit 监控文件或目录</h3>



<h4>1.1 在 audit 的策略里添加要监控的目录或文件</h4>



<h5>1.1.1 案例一：监控某个目录以及目录下的目录和文件</h5>



<pre class="wp-block-code"><code># vim /etc/audit/rules.d/audit.rules</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
-a exit,always -F dir=/tmp -F perm=rwxa</code></pre>



<p>（补充：这里以监控目录 /tmp 里的目录和文件为例）</p>



<h5>1.1.2 案例二：监控某个文件</h5>



<pre class="wp-block-code"><code># vim /etc/audit/rules.d/audit.rules</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
-a exit,always -S unlink -S unlinkat -S rmdir -S rename -S renameat -F path=/dev/null</code></pre>



<p>（补充：这里以监控目录 /dev/null 文件为例）</p>



<h4>1.2 让监控目录或文件的配置生效</h4>



<pre class="wp-block-code"><code># service auditd restart</code></pre>



<h3>步骤二：显示 audit 监控记录</h3>



<pre class="wp-block-code"><code># cat /var/log/audit</code></pre>



<p>（<br>补充：记录里的<br>1) nametype=CREATE 字段代表创建<br>2) nametype=NORMAL 字段代表普通<br>3) nametype=DELETE 字段代表删除<br>）</p>



<p>或者：</p>



<pre class="wp-block-code"><code># sudo ausearch -i -k user-modify</code></pre>



<p>（补充：这里以显示文件被修改的记录为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 命令安全的设置</title>
		<link>https://eternalcenter-sep-2022.github.io/command-secure/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 25 Jun 2022 13:37:57 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Process Security (系统进程安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26174</guid>

					<description><![CDATA[确保以下目录的所属主和所属组是 root，且其它用户没有写入权限：]]></description>
										<content:encoded><![CDATA[
<p>确保以下目录的所属主和所属组是 root，且其它用户没有写入权限：</p>



<pre class="wp-block-code"><code># ls -ld /usr/local/bin /usr/local/sbin /usr/bin/ /usr/sbin
dr-xr-xr-x. 2 root root 53248 Jun 24 15:09 /usr/bin/
drwxr-xr-x. 3 root root  4096 Jun 21  2021 /usr/local/bin
drwxr-xr-x. 2 root root     6 Jun 21  2021 /usr/local/sbin
dr-xr-xr-x. 2 root root 20480 Jun 24 15:09 /usr/sbin</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] 软件源的设置 （SLE 版） （通过本地镜像版）</title>
		<link>https://eternalcenter-sep-2022.github.io/repository-sle-local/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 20 Jun 2022 08:10:56 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System and System Software's Update and Patch (系统和系统软件的更新和补丁)]]></category>
		<category><![CDATA[System Computer & System Hardware & System Installation & System Upgradation (系统电脑 & 系统硬件 & 系统安装 & 系统升级)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Software (系统软件)]]></category>
		<category><![CDATA[System Upgradation (系统升级)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=25888</guid>

					<description><![CDATA[步骤一：加载本地镜像到系统光驱 （步骤略） 步骤二：挂载本地镜像 （补充：这里以挂载 /dev/sr1 到 /mnt 目录为例） 步骤三：添加本地镜里的软件源 3.1 添加本地镜里的软件源 （通过 zypper 命令） 或者： （补充：这里以将1) /mnt/Module-Basesystem 添加到软件源并命名为 SLE15-Base2) /mnt/Module-Legacy 添加到软件源并命名为 SLE15-Legacy3) /mnt/Module-Development-Tools 添加到软件源并命名为 SLE15-Tools为例） 3.1 添加本地镜里的软件源 （通过创建配置文件） 创建以下内容： 创建以下内容： 创建以下内容： （补充：这里以将1) /mnt/Module-Basesystem 添加到软件源并命名为 SLE15-Base2) /mnt/Module-Legacy 添加到软件源并命名为 SLE15-Legacy3) /mnt/Module-Development-Tools 添加到软件源并命名为 SLE15-Tools为例）]]></description>
										<content:encoded><![CDATA[
<h2>步骤一：加载本地镜像到系统光驱</h2>



<p>（步骤略）</p>



<h2>步骤二：挂载本地镜像</h2>



<pre class="wp-block-code"><code># mount /dev/cdrom /mnt</code></pre>



<p>（补充：这里以挂载 /dev/sr1 到 /mnt 目录为例）</p>



<h2>步骤三：添加本地镜里的软件源</h2>



<h4>3.1 添加本地镜里的软件源 （通过 zypper 命令）</h4>



<pre class="wp-block-code"><code># zypper ar file:/mnt/Module-Basesystem SLE15-Base
# zypper ar file:/mnt/Module-Legacy SLE15-Legacy
# zypper ar file:/mnt/Module-Development-Tools SLE15-Tools</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># zypper ar -f /mnt/Module-Basesystem SLE15-Base
# zypper ar -f /mnt/Module-Legacy SLE15-Legacy
# zypper ar -f /mnt/Module-Development-Tools SLE15-Tools</code></pre>



<p>（<br>补充：这里以将<br>1) /mnt/Module-Basesystem 添加到软件源并命名为 SLE15-Base<br>2) /mnt/Module-Legacy 添加到软件源并命名为 SLE15-Legacy<br>3) /mnt/Module-Development-Tools 添加到软件源并命名为 SLE15-Tools<br>为例<br>）</p>



<h4>3.1 添加本地镜里的软件源 （通过创建配置文件）</h4>



<pre class="wp-block-code"><code># vim /etc/zypp/repos.d/SLE15-Base.repo</code></pre>



<p>创建以下内容：</p>



<pre class="wp-block-code"><code>&#91;SLE15-Base]
enabled=1
autorefresh=0
baseurl=file:/mnt/Module-Development-Tools</code></pre>



<pre class="wp-block-code"><code># vim /etc/zypp/repos.d/SLE15-Legacy.repo</code></pre>



<p>创建以下内容：</p>



<pre class="wp-block-code"><code>&#91;SLE15-Legacy]
enabled=1
autorefresh=0
baseurl=file:/mnt/Module-Legacy</code></pre>



<pre class="wp-block-code"><code># vim /etc/zypp/repos.d/SLE15-Tools.repo</code></pre>



<p>创建以下内容：</p>



<pre class="wp-block-code"><code>&#91;SLE15-Tools]
enabled=1
autorefresh=0
baseurl=file:/mnt/Module-Basesystem/</code></pre>



<p>（<br>补充：这里以将<br>1) /mnt/Module-Basesystem 添加到软件源并命名为 SLE15-Base<br>2) /mnt/Module-Legacy 添加到软件源并命名为 SLE15-Legacy<br>3) /mnt/Module-Development-Tools 添加到软件源并命名为 SLE15-Tools<br>为例<br>）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] wtmp 日志保存时间默认策略的设置 （设置 last 命令可以显示多久以前记录）</title>
		<link>https://eternalcenter-sep-2022.github.io/wtmp/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 13:15:11 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24466</guid>

					<description><![CDATA[如果是 Rocky Linux &#38; RHEL： （补充：1) 影响的日志文件有 /var/log/wtmp （/var/log/wtmp）2) 每月将现在的日志文件进行备份并生成新的日志文件 （monthly）3) 日志文件权限是 0644 所属主是 root （create 0664 root utmp）4) 只有当日志文件超过 1 M 时，且达到备份的时间才会开始备份5) 备份的日志文件保留 5 份 （rotate 1）） 如果是 openSUSE &#38; SLE： （补充：1) 影响的日志文件有 /var/log/wtmp 和 /var/log/btmp （/var/log/wtmp /var/log/btmp）2) 对备份的日志文件进行压缩 （compress）3) 将 YYYYMMDD 格式的时间作为备份日志文件名的一部分 （dateext）4) 日志最多保存 365 天 （maxage 365）5) 备份的日志文件保留 99 份 （rotate 99）6) &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/wtmp/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] wtmp 日志保存时间默认策略的设置 （设置 last 命令可以显示多久以前记录）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>如果是 Rocky Linux &amp; RHEL：</p>



<pre class="wp-block-code"><code># cat /etc/logrotate.conf
......
/var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}
......</code></pre>



<p>（<br>补充：<br>1) 影响的日志文件有 /var/log/wtmp （/var/log/wtmp）<br>2) 每月将现在的日志文件进行备份并生成新的日志文件 （monthly）<br>3) 日志文件权限是 0644 所属主是 root （create 0664 root utmp）<br>4) 只有当日志文件超过 1 M 时，且达到备份的时间才会开始备份<br>5) 备份的日志文件保留 5 份 （rotate 1）<br>）</p>



<p>如果是 openSUSE &amp; SLE：</p>



<pre class="wp-block-code"><code># cat /etc/logrotate.d/wtmp
/var/log/wtmp /var/log/btmp {
    compress
    dateext
    maxage 365
    rotate 99
    size=+400k
    notifempty
    missingok
    copytruncate
}</code></pre>



<p>（<br>补充：<br>1) 影响的日志文件有 /var/log/wtmp 和 /var/log/btmp （/var/log/wtmp /var/log/btmp）<br>2) 对备份的日志文件进行压缩 （compress）<br>3) 将 YYYYMMDD 格式的时间作为备份日志文件名的一部分 （dateext）<br>4) 日志最多保存 365 天 （maxage 365）<br>5) 备份的日志文件保留 99 份 （rotate 99）<br>6) 现在的日志文件超过 400 k 就开始备份，不用考虑备份时间，且备份时间的相关设置也将无效 （size=+400k）<br>7) 如果现有日志文件是空文件，则不再对日志文件进行备份 （notifempty）<br>8) 如果现有日志文件丢失，则不报错直接生成新的日志文件 （missingok）<br>）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 环境变量 （$PATH） 的设置</title>
		<link>https://eternalcenter-sep-2022.github.io/environment-variable/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 06:23:44 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24425</guid>

					<description><![CDATA[内容一：临时设置环境变量 （$PATH） 1.1 查看当前环境变量 （$PATH） 值 1.2 临时设置环境变量 （$PATH） 值 内容二：永久设置环境变量 （$PATH） 2.1 给某个用户设置永久环境变量 2.1.1 切换到要永久设置环境变量 （$PATH）的用户 （补充：这里以切换到 root 用户为例） 2.1.2 配置 ~/.bashrc 配置文件 添加以下内容： （补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例） 2.1.3 让环境变量 （$PATH） 设置生效 2.2 全局永久设置环境变量 2.2.1 配置 /etc/profile 配置文件 添加以下内容： （补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例） 2.2.2 让环境变量 （$PATH） 设置生效]]></description>
										<content:encoded><![CDATA[
<h3 class="has-text-align-left">内容一：临时设置环境变量 （$PATH）</h3>



<h4 class="has-text-align-left">1.1 查看当前环境变量 （$PATH） 值</h4>



<pre class="wp-block-code"><code># echo $PATH</code></pre>



<h4>1.2 临时设置环境变量 （$PATH） 值</h4>



<pre class="wp-block-code"><code># export PATH=$PATH:/usr/locar/new/bin</code></pre>



<h3>内容二：永久设置环境变量 （$PATH）</h3>



<h4>2.1 给某个用户设置永久环境变量</h4>



<h5>2.1.1 切换到要永久设置环境变量 （$PATH）的用户</h5>



<pre class="wp-block-code"><code># su - root</code></pre>



<p>（补充：这里以切换到 root 用户为例）</p>



<h5>2.1.2 配置 ~/.bashrc 配置文件</h5>



<pre class="wp-block-code"><code># vim ~/.bashrc</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
export PATH=$PATH:/usr/locar/new/bin</code></pre>



<p>（补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例）</p>



<h5>2.1.3 让环境变量 （$PATH） 设置生效</h5>



<pre class="wp-block-code"><code># source ~/.bashrc</code></pre>



<h4>2.2 全局永久设置环境变量</h4>



<h5>2.2.1 配置 /etc/profile 配置文件</h5>



<pre class="wp-block-code"><code># vim /etc/profile</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
export PATH=$PATH:/usr/locar/new/bin</code></pre>



<p>（补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例）</p>



<h5>2.2.2 让环境变量 （$PATH） 设置生效</h5>



<pre class="wp-block-code"><code># source /etc/profile</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux sudo 命令安全的加强</title>
		<link>https://eternalcenter-sep-2022.github.io/sudo-secure-enhance/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 03:20:21 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24376</guid>

					<description><![CDATA[仅让 use pty 可以使用 sudo 命令 （避免后台进程使用 sudo 命令） 或者： 添加以下内容：]]></description>
										<content:encoded><![CDATA[
<p>仅让 use pty 可以使用 sudo 命令 （避免后台进程使用 sudo 命令）</p>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># visudo</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
Defaults use_pty</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux sudo 日志的开启</title>
		<link>https://eternalcenter-sep-2022.github.io/sudo-log/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 03:14:07 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24372</guid>

					<description><![CDATA[步骤一：开启 sudo 日志 或者： 添加以下内容： 步骤二：显示 sudo 日志 2.1 退出后重新登录 （步骤略） 2.2 显示 sudo 日志]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：开启 sudo 日志</h3>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># visudo</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
Defaults logfile="/var/log/sudo.log"</code></pre>



<h3>步骤二：显示 sudo 日志</h3>



<h4>2.1 退出后重新登录</h4>



<p>（步骤略）</p>



<h4>2.2 显示 sudo 日志</h4>



<pre class="wp-block-code"><code># cat /var/log/sudo.log</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] 解决 Linux 执行 ping 命令检测网络联通性时报错 “connect: Network is unreachable”</title>
		<link>https://eternalcenter-sep-2022.github.io/debug-connect-network-is-unreachable/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 15 Jun 2022 15:22:51 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24286</guid>

					<description><![CDATA[报错代码 分析 当配置的 IP 地址和子网掩码不包含配置的网关 IP 地址时，检测网络联通性时就会报此类错误 解决方法 配置正确的 IP 地址、子网掩码或网关 IP 地址（步骤略）]]></description>
										<content:encoded><![CDATA[
<h2> 报错代码</h2>



<pre class="wp-block-code"><code>connect: Network is unreachable</code></pre>



<h2>分析</h2>



<p>当配置的 IP 地址和子网掩码不包含配置的网关 IP 地址时，检测网络联通性时就会报此类错误</p>



<h2>解决方法</h2>



<p>配置正确的 IP 地址、子网掩码或网关 IP 地址<br>（步骤略）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] 解决 Linux 执行 crontab -e 命令时报错 “You (&#8230;&#8230;) are not allowed to use this program (crontab)”</title>
		<link>https://eternalcenter-sep-2022.github.io/debug-you-are-not-allowed-to-use-this-program-crontab/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 10 Jun 2022 10:07:51 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Performance (系统性能)]]></category>
		<category><![CDATA[System Port Security (系统端口安全)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Process (系统进程)]]></category>
		<category><![CDATA[System Process & System Performance (系统进程 & 系统性能)]]></category>
		<category><![CDATA[System Process Security (系统进程安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=23780</guid>

					<description><![CDATA[解决方法 如果在系统中没有 /etc/cron.deny 配置文件，在 /etc/cron.allow 配置文件中添加要使用 crontab -e 命令的用户 添加以下内容： （补充：这里以添加用户 zhumingyu 为例） 如果在系统中没有 /etc/cron.allow 配置文件，在 /etc/cron.allow 配置文件中删除要使用 crontab -e 命令的用户 删除以下内容： （补充：这里以删除用户 zhumingyu 为例）]]></description>
										<content:encoded><![CDATA[
<h2>解决方法</h2>



<p>如果在系统中没有 /etc/cron.deny 配置文件，在 /etc/cron.allow 配置文件中添加要使用 crontab -e 命令的用户</p>



<pre class="wp-block-code"><code># vim /etc/cron.allow</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
zhumingyu</code></pre>



<p>（补充：这里以添加用户 zhumingyu 为例）</p>



<p>如果在系统中没有 /etc/cron.allow 配置文件，在 /etc/cron.allow 配置文件中删除要使用 crontab -e 命令的用户</p>



<pre class="wp-block-code"><code># vim /etc/cron.allow</code></pre>



<p>删除以下内容：</p>



<pre class="wp-block-code"><code>......
zhumingyu
......</code></pre>



<p>（补充：这里以删除用户 zhumingyu 为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux SSH 常用安全加强配置项</title>
		<link>https://eternalcenter-sep-2022.github.io/sshd-security-enhance/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 06 Jun 2022 15:43:57 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Port Security (系统端口安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=23701</guid>

					<description><![CDATA[内容一：SSH 的配置文件 1.1 SSH 配置文件的位置 1.2 SSH 配置文件的所属主、所属组和权限 1.2.1 确保 SSH 配置文件的所属主和所属组都是 root 1.2.2 确保 SSH 配置文件的权限是 640 内容二：SSH 常用安全加强配置项 2.1 将 SSH 设置为 v2 版本 2.1.1 将 SSH 设置为 v2 版本的配置参数 2.1.2 将 SSH 设置为 v2 版本的参考步骤 2.2 忽略 Rhosts 认证 2.2.1 忽略 Rhosts 认证的配置参数 2.2.2 设置忽略 Rhosts 认证的参考步骤 2.3 禁止受信任的客户端通过 .rhosts 或 /etc/hosts.equiv &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/sshd-security-enhance/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux SSH 常用安全加强配置项"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：SSH 的配置文件</h3>



<h4>1.1 SSH 配置文件的位置</h4>



<pre class="wp-block-code"><code>/etc/ssh/sshd_config</code></pre>



<h4>1.2 SSH 配置文件的所属主、所属组和权限</h4>



<h5>1.2.1 确保 SSH 配置文件的所属主和所属组都是 root</h5>



<pre class="wp-block-code"><code># chown root:root /etc/ssh/sshd_config</code></pre>



<h5>1.2.2 确保 SSH 配置文件的权限是 640</h5>



<pre class="wp-block-code"><code># chmod 640 /etc/ssh/sshd_config</code></pre>



<h3>内容二：SSH 常用安全加强配置项</h3>



<h4>2.1 将 SSH 设置为 v2 版本</h4>



<h5>2.1.1 将 SSH 设置为 v2 版本的配置参数</h5>



<pre class="wp-block-code"><code>Protocol 2</code></pre>



<h5>2.1.2 将 SSH 设置为 v2 版本的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*Protocol .*/Protocol 2/g' /etc/ssh/sshd_config</code></pre>



<h4>2.2 忽略 Rhosts 认证</h4>



<h5>2.2.1 忽略 Rhosts 认证的配置参数</h5>



<pre class="wp-block-code"><code>IgnoreRhosts yes</code></pre>



<h5>2.2.2 设置忽略 Rhosts 认证的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/^.*IgnoreRhosts .*/IgnoreRhosts yes/g' /etc/ssh/sshd_config</code></pre>



<h4>2.3 禁止受信任的客户端通过 .rhosts 或 /etc/hosts.equiv 进行认证</h4>



<h5>2.3.1 设置禁止受信任的客户端通过 .rhosts 或 /etc/hosts.equiv 进行认证的配置参数</h5>



<pre class="wp-block-code"><code>HostbasedAuthentication no</code></pre>



<h5>2.3.2 设置禁止受信任的客户端通过 .rhosts 或 /etc/hosts.equiv 进行认证的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*HostbasedAuthentication .*/HostbasedAuthentication no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.4 禁止使用用户提交的 SSH 环境</h4>



<h5>2.4.1 设置禁止使用用户提交的 SSH 环境的配置参数</h5>



<pre class="wp-block-code"><code>PermitUserEnvironment no</code></pre>



<h5>2.4.2 设置禁止使用用户提交的 SSH 环境的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*PermitUserEnvironment .*/PermitUserEnvironment no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.5 禁止 root 用户通过 SSH 登录</h4>



<h5>2.5.1 禁止 root 用户通过 SSH 登录的配置参数</h5>



<pre class="wp-block-code"><code>PermitRootLogin no</code></pre>



<h5>2.5.2 设置禁止 root 用户通过 SSH 登录的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*PermitRootLogin .*/PermitRootLogin no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.6 禁止空密码 SSH 登录</h4>



<h5>2.6.1 禁止空密码 SSH 登录的配置参数</h5>



<pre class="wp-block-code"><code>PermitEmptyPasswords no</code></pre>



<h5>2.6.2 设置禁止空密码 SSH 登录的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*PermitEmptyPasswords .*/PermitEmptyPasswords no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.7 将 SSH 登录信息写入系统日志</h4>



<h5>2.7.1 将 SSH 登录信息写入系统日志的配置参数</h5>



<pre class="wp-block-code"><code>SyslogFacility AUTH</code></pre>



<h5>2.7.2 设置将 SSH 登录信息写入系统日志的参看步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*SyslogFacility .*/SyslogFacility AUTH/g' /etc/ssh/sshd_config</code></pre>



<h4>2.8 记录全部 SSH 信息</h4>



<h5>2.8.1 记录全部 SSH 信息的配置参数</h5>



<pre class="wp-block-code"><code>LogLevel INFO</code></pre>



<h5>2.8.2 设置记录全部 SSH 信息的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*LogLevel .*/LogLevel INFO/' /etc/ssh/sshd_config</code></pre>



<h4>2.9 设置最大尝试登录失败数和触发尝试登录失败日志的登录失败数</h4>



<h5>2.9.1 设置最大尝试登录失败数和触发尝试登录失败日志的登录失败数的配置参数</h5>



<pre class="wp-block-code"><code>MaxAuthTries 5</code></pre>



<p>（补充：这里以设置最大尝试登录失败数是 5 次为例，如果此时尝试登录次数超过 2，则系统日志中会出现登录失败的记录）</p>



<h5>2.9.2 设置最大尝试登录失败数和触发尝试登录失败日志的登录失败数的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*MaxAuthTries .*/MaxAuthTries 5/g' /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以设置最大尝试登录失败数是 5 次为例，如果此时尝试登录次数超过 2，则系统日志中会出现登录失败的记录）</p>



<h4>2.10 设置 SSH 登录时密码输入的时间</h4>



<h5>2.10.1 设置 SSH 登录时密码输入的时间的配置参数</h5>



<pre class="wp-block-code"><code>LoginGraceTime 600</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>LoginGraceTime 10m</code></pre>



<p>（补充：这里以设置 SSH 登录时密码输入的时间为 600 秒为例）</p>



<h5>2.10.2 设置 SSH 登录时密码输入的时间都参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*LoginGraceTime .*/LoginGraceTime 600/g' /etc/ssh/sshd_config</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># sed -i 's/.*LoginGraceTime .*/LoginGraceTime 10m/g' /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以设置 SSH 登录时密码输入的时间为 600 秒为例）</p>



<h4>2.11 禁止 SSH 图形界面转发</h4>



<h5>2.11.1 禁止 SSH 图形界面转发的配置参数</h5>



<pre class="wp-block-code"><code>X11Forwarding no</code></pre>



<h5>2.11.1 设置禁止 SSH 图形界面转发的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*X11Forwarding .*/X11Forwarding no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.12 禁止 SSH TCP 转发</h4>



<h5>2.12.1 设置禁止 SSH TCP 转发的配置参数</h5>



<pre class="wp-block-code"><code>AllowTcpForwarding no</code></pre>



<h5>2.12.2 设置禁止 SSH TCP 转发的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*AllowTcpForwarding .*/AllowTcpForwarding no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.13 不显示上次 SSH 登录的信息，例如时间和地点等</h4>



<h5>2.13.1 设置不显示上次 SSH 登录的信息，例如时间和地点等的配置参数</h5>



<pre class="wp-block-code"><code>PrintMotd no</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>PrintLastLog no</code></pre>



<h5>2.13.1 设置不显示上次 SSH 登录的信息，例如时间和地点等的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*PrintMotd .*/PrintMotd no/g' /etc/ssh/sshd_config</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># sed -i 's/.*PrintLastLog .*/PrintLastLog no/g' /etc/ssh/sshd_config</code></pre>



<h4>2.14 设置同时只能让几个 SSH 用户登录</h4>



<h5>2.14.1 设置同时只能让几个 SSH 用户登录的配置参数</h5>



<pre class="wp-block-code"><code>MaxStartups 10:30:60</code></pre>



<p>（<br>补充：这里以<br>1) 最多同时只能让 10 个用户发起 SSH 登录请求，超过此数量的登录请求会被拒绝<br>2) 当 SSH 连接数超过上限时 （这里设置的是 10 个），再新发起 SSH 登录请求的用户，会有 30% 的概率被拒绝<br>3) 当 SSH 连接数超过 60 时，再新发起 SSH 登录请求的用户全部会被拒绝，这里的 30 参数将会无效<br>）</p>



<h5>2.14.2 设置同时只能让几个 SSH 用户登录的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*MaxStartups .*/MaxStartups 10:30:60/g' /etc/ssh/sshd_config</code></pre>



<p>（<br>补充：这里以<br>1) 最多同时只能让 10 个用户发起 SSH 登录请求，超过此数量的登录请求会被拒绝<br>2) 当 SSH 连接数超过上限时 （这里设置的是 10 个），再新发起 SSH 登录请求的用户，会有 30% 的概率被拒绝<br>3) 当 SSH 连接数超过 60 时，再新发起 SSH 登录请求的用户全部会被拒绝，这里的 30 参数将会无效<br>）</p>



<h4>2.15 设置每个连接可以开启会话的个数</h4>



<h5>2.15.1 设置每个连接可以开启会话的个数的配置参数</h5>



<pre class="wp-block-code"><code>MaxSessions 4</code></pre>



<p>（补充：这里以设置每个连接可以开启 4 个会话为例，默认值为 10）</p>



<h5>2.15.2 设置每个连接可以开启会话的个数的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*MaxSessions .*/MaxSessions 4/g' /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以设置每个连接可以开启 4 个会话为例，默认值为 10）</p>



<h4>2.16 设置客户端 SSH 空闲超时时间</h4>



<h5>2.16.1 设置客户端 SSH 空闲超时时间的配置参数</h5>



<pre class="wp-block-code"><code>ClientAliveInterval 100
ClientAliveCountMax 3</code></pre>



<p>（补充：这里以设置客户端 SSH 空闲超时时间为 100 * 3=300 秒为例）</p>



<h5>2.16.2 设置客户端 SSH 空闲超时时间的参考步骤</h5>



<pre class="wp-block-code"><code># sed -i 's/.*ClientAliveInterval .*/ClientAliveInterval 100/g' /etc/ssh/sshd_config
# sed -i 's/.*ClientAliveCountMax .*/ClientAliveCountMax 3/g' /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以设置客户端 SSH 空闲超时时间为 100 * 3=300 秒为例）</p>



<h4>2.17 指定安全的 SSH Ciphers 加密算法</h4>



<h5>2.17.1 设置 SSH Ciphers 加密算法的配置参数</h5>



<pre class="wp-block-code"><code>Ciphers aes256-ctr,aes192-ctr,aes128-ctr</code></pre>



<p>（补充：这里以使用 aes256-ctr、aes192-ctr 和 aes128-ctr SSH Ciphers 加密算法为例）</p>



<h5>2.17.2 设置 SSH Ciphers 加密算法的参考步骤</h5>



<pre class="wp-block-code"><code># echo "Ciphers aes256-ctr,aes192-ctr,aes128-ctr" &gt;&gt; /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以使用 aes256-ctr、aes192-ctr 和 aes128-ctr SSH Ciphers 加密算法为例）</p>



<h4>2.18 指定安全的 SSH MACs 加密算法</h4>



<h5>2.18.1 设置 SSH MACs 加密算法的配置参数</h5>



<pre class="wp-block-code"><code>MACs hmac-sha2-512,hmac-sha2-256</code></pre>



<p>（补充：这里以使用 hmac-sha2-512 和 hmac-sha2-256 SSH MACs 加密算法为例）</p>



<h5>2.18.2 设置 SSH MACs 加密算法的参考步骤</h5>



<pre class="wp-block-code"><code># echo "MACs hmac-sha2-512,hmac-sha2-256" &gt;&gt; /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以使用 hmac-sha2-512 和 hmac-sha2-256 SSH MACs 加密算法为例）</p>



<h4>2.19 指定安全的 SSH KexAlgorithms 加密算法</h4>



<h5>2.19.1 设置 SSH KexAlgorithms 加密算法的配置参数</h5>



<pre class="wp-block-code"><code>KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256</code></pre>



<p>（补充：这里以使用 ecdh-sha2-nistp521、ecdh-sha2-nistp384、ecdh-sha2-nistp256 和 diffie-hellman-group-exchange-sha256 SSH KexAlgorithms 加密算法为例）</p>



<h5>2.19.2 设置 SSH KexAlgorithms 加密算法的参考步骤</h5>



<pre class="wp-block-code"><code># echo "KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256" &gt;&gt; /etc/ssh/sshd_config</code></pre>



<p>（补充：这里以使用 ecdh-sha2-nistp521、ecdh-sha2-nistp384、ecdh-sha2-nistp256 和 diffie-hellman-group-exchange-sha256 SSH KexAlgorithms 加密算法为例）</p>



<h4>2.20 只允许某 IP 地址可以 SSH 本服务器</h4>



<h5>2.20.1 启用 UseTCPWrappers 参数</h5>



<pre class="wp-block-code"><code># vim /etc/ssh/sshd_config</code></pre>



<p>将部分内容修改如下：</p>



<pre class="wp-block-code"><code>......
UseTCPWrappers yes
......</code></pre>



<h5>2.20.2 禁止所有 IP 地址可以 SSH 本服务器</h5>



<pre class="wp-block-code"><code># vim /etc/hosts.deny</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
sshd : ALL </code></pre>



<h5>2.20.3 只允许某 IP 地址可以 SSH 本服务器</h5>



<pre class="wp-block-code"><code># vim /etc/hosts.deny</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
sshd : 192.168.0.1/32 : ALLOW
sshd : ALL</code></pre>



<p>（补充：这里以允许 IP 地址 192.168.0.1 可以 SSH 本服务器为例）</p>



<p>（注意：这和防火墙的策略一样从上往下匹配及停止，所以允许某 IP 地址可以 SSH 本服务器的策略一定要加在禁止所有 IP 地址可以 SSH 本服务器的策略之前）</p>



<h4>2.21 只允许从某 IP 地址来的某用户可以 SSH 本服务器</h4>



<pre class="wp-block-code"><code># vim /etc/ssh/sshd_config</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
AllowUsers zhumingyu mingyuzhu@192.168.1.1
AllowGroups zhu</code></pre>



<p>（<br>补充：这里以<br>1) 允许用户 zhumingyu 可以登录<br>2) 允许从 192.168.1.1 来的用户 mingyuzhu 可以登录<br>3) 允许属于组 zhu 的用户可以登录<br>其它用户不能登录<br>为例<br>）</p>



<h4>2.22 禁止某 IP 地址可以 SSH 本服务器</h4>



<h5>2.22.1 启用 UseTCPWrappers 参数</h5>



<pre class="wp-block-code"><code># vim /etc/ssh/sshd_config</code></pre>



<p>将部分内容修改如下：</p>



<pre class="wp-block-code"><code>......
UseTCPWrappers yes
......</code></pre>



<h5>2.22.2 禁止某 IP 地址可以 SSH 本服务器</h5>



<pre class="wp-block-code"><code># vim /etc/hosts.deny</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>sshd : 192.168.0.1/32 : ALLOW</code></pre>



<p>（补充：这里以禁止 IP 地址 192.168.0.1 可以 SSH 本服务器为例）</p>



<h4>2.23 禁止从某 IP 地址来的某用户可以 SSH 本服务器</h4>



<pre class="wp-block-code"><code># vim /etc/ssh/sshd_config</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
DenyUsers zhumingyu mingyuzhu@192.168.1.1
DenyGroups zhu</code></pre>



<p>（<br>补充：这里以<br>1) 禁止用户 zhumingyu 登录<br>2) 禁止从 192.168.1.1 来的用户 mingyuzhu 登录<br>3) 禁止属于组 zhu 的用户登录<br>其它用户都可以登录<br>为例<br>）</p>



<h3>内容三：重启 sshd 服务</h3>



<pre class="wp-block-code"><code># systemctl restart sshd</code></pre>



<p>（补充：内容二里的参数只有重启了 sshd 服务后才能生效）</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
