<?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 Login Security (系统登录安全) &#8211; Eternal Center</title>
	<atom:link href="https://eternalcenter-may-1-2022.github.io/category/system/system-network-system-security-system-log/system-security/system-login-security/feed/" rel="self" type="application/rss+xml" />
	<link>https://eternalcenter-may-1-2022.github.io/</link>
	<description></description>
	<lastBuildDate>Fri, 29 Apr 2022 14:47:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>[步骤] Linux SSH 密钥的批量更新</title>
		<link>https://eternalcenter-may-1-2022.github.io/ssh-key-batch-renew/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 29 Apr 2022 14:36:55 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></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-may-1-2022.github.io/?p=23423</guid>

					<description><![CDATA[步骤目录： 步骤一：生成新的 SSH 密钥1.1 进入 ~/.ssh 目录1.2 生成新的 SSH 密钥 步骤二：将新的 SSH 公钥拷贝到目标服务器 步骤三：更新 SSH 密钥3.1 更新 SSH 私钥3.1.1 备份旧有的 SSH 私钥3.1.2 更新 SSH 私钥3.2 更新 SSH 公钥3.2.1 备份旧有的 SSH 公钥3.2.2 更新 SSH 公钥 步骤四：删除目标服务器的旧有 SSH 公钥4.1 删除目标服务器的旧有 SSH 公钥4.2 确定目标服务器就有的 SSH 已经删除 具体的操作步骤： 步骤一：生成新的 SSH 密钥1.1 进入 ~/.ssh 目录 1.2 生成新的 SSH 密钥 步骤二：将新的 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/ssh-key-batch-renew/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] Linux SSH 密钥的批量更新"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2>步骤目录：</h2>



<h4>步骤一：生成新的 SSH 密钥<br>1.1 进入 ~/.ssh 目录<br>1.2 生成新的 SSH 密钥</h4>



<h4>步骤二：将新的 SSH 公钥拷贝到目标服务器</h4>



<h4>步骤三：更新 SSH 密钥<br>3.1 更新 SSH 私钥<br>3.1.1 备份旧有的 SSH 私钥<br>3.1.2 更新 SSH 私钥<br>3.2 更新 SSH 公钥<br>3.2.1 备份旧有的 SSH 公钥<br>3.2.2 更新 SSH 公钥</h4>



<h4>步骤四：删除目标服务器的旧有 SSH 公钥<br>4.1 删除目标服务器的旧有 SSH 公钥<br>4.2 确定目标服务器就有的 SSH 已经删除</h4>



<h2>具体的操作步骤：</h2>



<h4>步骤一：生成新的 SSH 密钥<br>1.1 进入 ~/.ssh 目录</h4>



<pre class="wp-block-code"><code># cd ~/.ssh</code></pre>



<h4>1.2 生成新的 SSH 密钥</h4>



<pre class="wp-block-code"><code># ssh-keygen -b 4096 -t rsa -C "&lt;content&gt;" -f "&lt;public private key name&gt;"</code></pre>



<h4>步骤二：将新的 SSH 公钥拷贝到目标服务器</h4>



<pre class="wp-block-code"><code># for i in `cat &lt;server list&gt;`;do echo $i;ssh-copy-id -i ~/.ssh/&lt;public private key name&gt;.pub $i;echo;done</code></pre>



<h4>步骤三：更新 SSH 密钥<br>3.1 更新 SSH 私钥<br>3.1.1 备份旧有的 SSH 私钥</h4>



<pre class="wp-block-code"><code># mv id_rsa id_rsa.backup</code></pre>



<h4>3.1.2 更新 SSH 私钥</h4>



<pre class="wp-block-code"><code># cp &lt;public private key name&gt; id_rsa</code></pre>



<h4>3.2 更新 SSH 公钥<br>3.2.1 备份旧有的 SSH 公钥</h4>



<pre class="wp-block-code"><code># mv id_rsa.pub id_rsa.pub.backup</code></pre>



<h4>3.2.2 更新 SSH 公钥</h4>



<pre class="wp-block-code"><code># cp &lt;public private key name&gt;.pub id_rsa.pub</code></pre>



<h4>步骤四：删除目标服务器的旧有 SSH 公钥<br>4.1 删除目标服务器的旧有 SSH 公钥</h4>



<pre class="wp-block-code"><code># for i in `cat &lt;server list&gt;`;do echo $i;ssh $i "sed -i /&lt;old SSH key content&gt;/d ~/.ssh/authorized_keys";echo;done</code></pre>



<h4>4.2 确定目标服务器就有的 SSH 已经删除</h4>



<pre class="wp-block-code"><code># for i in `cat &lt;server list&gt;`;do echo $i;ssh $i "cat ~/.ssh/authorized_keys | egrep -v '&lt;content&gt;'";echo;done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 系统被删根 （rm -rf /*） 后锁定删根 （rm -rf /*） 用户的尝试 （系统层面）</title>
		<link>https://eternalcenter-may-1-2022.github.io/rm-rf-user/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Thu, 28 Apr 2022 15:03:04 +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 (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=23353</guid>

					<description><![CDATA[步骤目录： 步骤一：系统被删根 （rm -rf /*） 后的现象 步骤二：挂载官方镜像 步骤三：登录拯救模式3.1 进入拯救模式3.2 登录拯救模式 步骤四：在救援模式确定系统的根目录分区 步骤五：在救援模式将系统的分区挂载到救援模式的 /mnt 目录5.1 在救援模式将系统的根分区挂载到救援模式的 /mnt 目录5.2 在救援模式将救援模式的 /dev 目录关联到救援模式的 /mnt/dev 目录5.3 在救援模式将救援模式的 /proc 目录关联到救援模式的 /mnt/proc 目录5.4 在救援模式将救援模式的 /sys 目录关联到救援模式的 /mnt/sys 目录5.5 在救援模式将救援模式的 /run 目录关联到救援模式的 /mnt/run 目录 步骤六：显示系统被删根 （rm -rf /*） 后的现象6.1 尝试将当前根目录从救援模式的根目录切换到系统的根目录时会报错 “chroot: failed to run command #/bin/bash#: No such file or directory”6.2 在救援模式显示 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/rm-rf-user/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] Linux 系统被删根 （rm -rf /*） 后锁定删根 （rm -rf /*） 用户的尝试 （系统层面）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2>步骤目录：</h2>



<h4>步骤一：系统被删根 （rm -rf /*） 后的现象</h4>



<h4>步骤二：挂载官方镜像</h4>



<h4>步骤三：登录拯救模式<br>3.1 进入拯救模式<br>3.2 登录拯救模式</h4>



<h4>步骤四：在救援模式确定系统的根目录分区</h4>



<h4>步骤五：在救援模式将系统的分区挂载到救援模式的 /mnt 目录<br>5.1 在救援模式将系统的根分区挂载到救援模式的 /mnt 目录<br>5.2 在救援模式将救援模式的 /dev 目录关联到救援模式的 /mnt/dev 目录<br>5.3 在救援模式将救援模式的 /proc 目录关联到救援模式的 /mnt/proc 目录<br>5.4 在救援模式将救援模式的 /sys 目录关联到救援模式的 /mnt/sys 目录<br>5.5 在救援模式将救援模式的 /run 目录关联到救援模式的 /mnt/run 目录</h4>



<h4>步骤六：显示系统被删根 （rm -rf /*） 后的现象<br>6.1 尝试将当前根目录从救援模式的根目录切换到系统的根目录时会报错 “chroot: failed to run command #/bin/bash#: No such file or directory”<br>6.2 在救援模式显示 /boot 目录里的文件时，会发现此目录下只有 grub2 目录，而此 grub2 目录里也是空的<br>6.3 在救援模式显示 /bin 目录时，会显示并无此目录<br>6.4 在救援模式显示 /etc 目录里的文件时，会发现此目录下只有 lvm 文件</h4>



<h4>步骤七：在救援模式修复系统的 /bin 目录和里面的文件<br>7.1 在救援模式创建 /mnt/bin 目录<br>7.2 在救援模式挂载官方镜像<br>7.2.1 在救援模式创建用于挂载镜像的 /media 目录<br>7.2.2 在救援模式挂将官方镜像挂载到 /media 目录<br>7.3 在救援模式安装 bash 软件<br>7.3.1 在救援模式安装拷贝 bash 软件包到当前目录<br>7.3.2 在救援模式创建用于安装 bash 软件的 bash 目录<br>7.3.3 在救援模式进入 bash 目录<br>7.3.4 在救援模式安装 bash 软件<br>7.3.5 在救援模式显示安装 bash 软件后生成的目录<br>7.4 在救援模式将 bin 目录拷贝到 /mnt/bin 目录</h4>



<h4>步骤八：将当前的根目录从救援模式的根目录切换到系统的根目录<br>8.1 将当前的根目录从救援模式的根目录切换到系统的根目录<br>8.2 在系统模式下确认当前的挂载状态<br>8.3 在系统模式下确认当前根目录下的目录</h4>



<h4>步骤九：锁定有删根 （rm -rf /*<em>） 操作的用户</em><br><em>9.1 在系统模式显示历史命令以确认有没有用户输入过 rm -rf /* 命令</em><br><em>9.2 在系统模式显示用户登录记录</em><br><em>9.3 根据步骤 9.1 和步骤 9.2 推测是哪个用户进行过删根 （rm -rf /</em>*） 操作</h4>



<h2>具体的操作步骤：</h2>



<h4>步骤一：系统被删根 （rm -rf /*） 后的现象总结</h4>



<p>1) 系统无法被 ssh<br>2) 通过 console 口登录系统在输入密码时会卡住<br>3) 尝试将当前根目录从救援模式的根目录切换到系统的根目录时会报错 “chroot: failed to run command #/bin/bash#: No such file or directory”<br>4) 重启系统后无法进入系统，并提示：/grub2/i386-pc/normoal.mod not found gpt<br>5）在救援模式显示 /boot 目录里的文件时，会发现此目录下只有 grub2 目录，而此 grub2 目录里也是空的<br>6) 在救援模式显示 /bin 目录时，会显示并无此目录<br>7) 在救援模式显示 /etc 目录里的文件时，会发现此目录下只有 lvm 文件</p>



<h4>步骤二：挂载官方镜像</h4>



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



<h4>步骤三：登录拯救模式<br>3.1 进入拯救模式</h4>



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



<h4>3.2 登录拯救模式</h4>



<pre class="wp-block-code"><code>rescue login:root</code></pre>



<h4>步骤四：在救援模式确定系统的根目录分区</h4>



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



<p>（<br>补充：<br>1) 物理分区可以使用 lsblk 命令和 fdisk -l 命令辅助确定<br>2) 逻辑分区还可以可以使用 pvs 命令和 lvs 命令辅助确定<br>）</p>



<h4>步骤五：在救援模式将系统的分区挂载到救援模式的 /mnt 目录<br>5.1 在救援模式将系统的根分区挂载到救援模式的 /mnt 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount &lt;root spartition&gt; /mnt</code></pre>



<p>（<br>补充：<br>1) 如果是物理分区，系统的根分区就在救援模式的 /dev/ 目录里，例如救援模式的 /dev/sda1<br>2) 如果是逻辑分区，Rocky Linux &amp; RHEL 的系统根分区就是救援模式里的 /dev/&lt;volume group>/&lt;logical volume> 例如救援模式里的 /dev/vg/lv，openSUSE &amp; SUSE 的系统根分区就是救援模式里的 /dev/mapper/&lt;volume group>-&lt;logical volume> 例如救援模式里的 /dev/mapper/vg-lv<br>）</p>



<h4>5.2 在救援模式将救援模式的 /dev 目录关联到救援模式的 /mnt/dev 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount --bind /dev /mnt/dev</code></pre>



<p>（补充：此时所有对救援模式的 /mnt/dev 目录的访问都会变成对救援模式的 /dev 目录的访问）</p>



<h4>5.3 在救援模式将救援模式的 /proc 目录关联到救援模式的 /mnt/proc 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount --bind /proc /mnt/proc</code></pre>



<p>（补充：此时所有对救援模式的 /mnt/proc 目录的访问都会变成对救援模式的 /proc 目录的访问）</p>



<h4>5.4 在救援模式将救援模式的 /sys 目录关联到救援模式的 /mnt/sys 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount --bind /sys /mnt/sys</code></pre>



<p>（补充：此时所有对救援模式的 /mnt/sys 目录的访问都会变成对救援模式的 /sys 目录的访问）</p>



<h4>5.5 在救援模式将救援模式的 /run 目录关联到救援模式的 /mnt/run 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount --bind /run /mnt/run</code></pre>



<p>（补充：此时所有对救援模式的 /mnt/run 目录的访问都会变成对救援模式的 /run 目录的访问）</p>



<h4>步骤六：显示系统被删根 （rm -rf /*） 后的现象<br>6.1 尝试将当前根目录从救援模式的根目录切换到系统的根目录时会报错 “chroot: failed to run command #/bin/bash#: No such file or directory”</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # chroot /mnt
chroot: failed to run command #/bin/bash#: No such file or directory</code></pre>



<p>（补充：这里以 /mnt 作为系统根目录为例）</p>



<p>（注意：因为在使用 rm -rf /* 命令删过根以后，/bin/bash 已经被删除，所以会报错：chroot: failed to run command #/bin/bash#: No such file or directory）</p>



<h4>6.2 在救援模式显示 /boot 目录里的文件时，会发现此目录下只有 grub2 目录，而此 grub2 目录里也是空的</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls /boot 
grub2</code></pre>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls /boot</code></pre>



<p>此步骤也可以通过以下方法实现：</p>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls -l /mounts/mp_0001/boot
total 0
......grub2</code></pre>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls -l /mounts/mp_0001/boot/grub2
total 0</code></pre>



<h4>6.3 在救援模式显示 /bin 目录时，会显示并无此目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls /mnt/bin
ls: cannot access '/mnt/bin' : No such file or directory</code></pre>



<h4>6.4 在救援模式显示 /etc 目录里的文件时，会发现此目录下只有 lvm 文件</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # ls /etc/
lvm</code></pre>



<h4>步骤七：在救援模式修复系统的 /bin 目录和里面的文件<br>7.1 在救援模式创建 /mnt/bin 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mkdir /mnt/bin</code></pre>



<h4>7.2 在救援模式挂载官方镜像<br>7.2.1 在救援模式创建用于挂载镜像的 /media 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # /media</code></pre>



<h4>7.2.2 在救援模式挂将官方镜像挂载到 /media 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mount /dev/dvd /media</code></pre>



<h4>7.3 在救援模式安装 bash 软件<br>7.3.1 在救援模式安装拷贝 bash 软件包到当前目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # cp /media/suse/x86_64/bash-4.3-83.23.1.x86_64.rpm .</code></pre>



<p>（补充：这里以拷贝 /media/suse/x86_64/bash-4.3-83.23.1.x86_64.rpm）</p>



<h4>7.3.2 在救援模式创建用于安装 bash 软件的 bash 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # mkdir bash</code></pre>



<h4>7.3.3 在救援模式进入 bash 目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ # cd bash</code></pre>



<h4>7.3.4 在救援模式安装 bash 软件</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ /bash # rpm2cpio ../bash-4.3-83.23.1.x86_64.rpm | cpio -ivd</code></pre>



<p>（补充：这里以安装 bash-4.3-83.23.1.x86_64.rpm 软件为例）</p>



<h4>7.3.5 在救援模式显示安装 bash 软件后生成的目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ /bash # ls
bin etc usr</code></pre>



<h4>7.4 在救援模式将 bin 目录拷贝到 /bin/mnt 目录下</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ /bash # cp -rpv bin /mnt/bin
'bin/bash' -&gt; '/mnt/bin/bash'
'bin/sh' -&gt; '/mnt/bin/sh'</code></pre>



<h4>步骤八：将当前的根目录从救援模式的根目录切换到系统的根目录<br>8.1 将当前的根目录从救援模式的根目录切换到系统的根目录</h4>



<pre class="wp-block-code"><code>tty1:rescue:~ /bash # chroot /mnt</code></pre>



<p>（补充：这里以 /mnt 作为系统根目录为例）</p>



<h4>8.2 在系统模式下确认当前的挂载状态</h4>



<pre class="wp-block-code"><code>bash-4.3# mount -a</code></pre>



<h4>8.3 在系统模式下确认当前根目录下的目录</h4>



<pre class="wp-block-code"><code>bash-4.3# ls
bin boot dev home lib lib64 mnt opt proc root run sbin selinux srv sys tmp usr var</code></pre>



<h4>步骤九：锁定有删根 （rm -rf /*<em>） 操作的用户 </em><br><em>9.1 在系统模式显示历史命令以确认有没有用户输入过 rm -rf /</em> 命令</h4>



<pre class="wp-block-code"><code>bash-4.3# history | less</code></pre>



<h4>9.2 在系统模式显示用户登录记录</h4>



<pre class="wp-block-code"><code>bash-4.3# last | less</code></pre>



<p>（补充：此时会显示最后登录系统的用户、登陆时间、且可能最后 1 个登录系统的用户无退出时间）</p>



<h4>9.3 根据步骤 9.1 和步骤 9.2 推测是哪个用户进行过删根 （rm -rf /*） 操作</h4>



<p>（步骤略）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] iptables 防火墙规则持久化 （让防火墙规则开机自启）</title>
		<link>https://eternalcenter-may-1-2022.github.io/iptables-rule-permanent/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 25 Apr 2022 07:28:11 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Firewall (系统防火墙)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Port Security (系统端口安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=23270</guid>

					<description><![CDATA[内容一：Rocky Linux &#38; RHEL iptables 防火墙规则持久化 内容二：Rocky Linux &#38; RHEL 和 openSUSE &#38; SUSE iptables 防火墙规则持久化2.1 导出现在 iptables 防火墙的规则 （补充：这里以将 iptables 防火墙规则导出到 /root/iptables_save 文件为例） 2.2 创建用于加载 iptables 防火墙规则的 systemctl 管理文件 创建以下内容： （补充：这里以创建 systemctl 管理文件 /etc/systemd/system/iptables_save.service 将 /root/iptables_save 文件里的内容导入到 iptables 防火墙为例） 2.3 加载刚刚创建的 systemctl 管理文件 2.4 给刚刚创建的 systemctl 管理文件添加执行权限 （补充：这里以给 systemctl 管理文件 /etc/systemd/system/iptables_save.service 添加执行权限为例） 2.5 让防火墙规则开机自启 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/iptables-rule-permanent/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] iptables 防火墙规则持久化 （让防火墙规则开机自启）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h4>内容一：Rocky Linux &amp; RHEL iptables 防火墙规则持久化</h4>



<pre class="wp-block-code"><code># service iptables save</code></pre>



<h4>内容二：Rocky Linux &amp; RHEL 和 openSUSE &amp; SUSE iptables 防火墙规则持久化<br>2.1 导出现在 iptables 防火墙的规则</h4>



<pre class="wp-block-code"><code># iptables-save &gt; /root/iptables_save</code></pre>



<p>（补充：这里以将 iptables 防火墙规则导出到 /root/iptables_save 文件为例）</p>



<h4>2.2 创建用于加载 iptables 防火墙规则的 systemctl 管理文件</h4>



<pre class="wp-block-code"><code># vim /etc/systemd/system/iptables_save.service</code></pre>



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



<pre class="wp-block-code"><code>&#91;Unit]
Description=iptables_save
After=default.target

&#91;Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore &lt; /root/iptables_save

&#91;Install]
WantedBy=default.target</code></pre>



<p>（补充：这里以创建 systemctl 管理文件 /etc/systemd/system/iptables_save.service 将 /root/iptables_save 文件里的内容导入到 iptables 防火墙为例）</p>



<h4>2.3 加载刚刚创建的 systemctl 管理文件</h4>



<pre class="wp-block-code"><code># systemctl daemon-reload</code></pre>



<h4>2.4 给刚刚创建的 systemctl 管理文件添加执行权限</h4>



<pre class="wp-block-code"><code># chmod u+x /etc/systemd/system/iptables_save.service</code></pre>



<p>（补充：这里以给 systemctl 管理文件 /etc/systemd/system/iptables_save.service 添加执行权限为例）</p>



<h4>2.5 让防火墙规则开机自启</h4>



<pre class="wp-block-code"><code># systemctl enable iptables_save.service</code></pre>



<p>（补充：这里以开机自启 iptables_save.service 服务为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] iptables 防火墙规则的导出和导入</title>
		<link>https://eternalcenter-may-1-2022.github.io/iptables-rule-export-import/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 25 Apr 2022 07:20:19 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Firewall (系统防火墙)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Port Security (系统端口安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=23267</guid>

					<description><![CDATA[内容一：导出 iptables 防火墙规则 （补充：这里以将 iptables 防火墙规则导出到 /root/iptables_save 文件为例） 内容二：导入 iptables 防火墙规则 （补充：这里以将 /root/iptables_save 文件里的内容导入到 iptables 防火墙为例）]]></description>
										<content:encoded><![CDATA[
<h4>内容一：导出 iptables 防火墙规则</h4>



<pre class="wp-block-code"><code># iptables-save &gt; /root/iptables_save</code></pre>



<p>（补充：这里以将 iptables 防火墙规则导出到 /root/iptables_save 文件为例）</p>



<h4>内容二：导入 iptables 防火墙规则</h4>



<pre class="wp-block-code"><code># iptables-restore &lt; /root/iptables_save</code></pre>



<p>（补充：这里以将 /root/iptables_save 文件里的内容导入到 iptables 防火墙为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] 解决 Linux 运行 authselect 命令时报错 “[error] [/etc/authselect/system-auth] has unexpected content!” 或者 “[error] [/etc/authselect/password-auth] has unexpected content!”</title>
		<link>https://eternalcenter-may-1-2022.github.io/debug-error-etc-authselect-system-auth-has-unexpected-content-or-error-etc-authselect-passwor/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 11 Apr 2022 15:40:00 +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>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=23013</guid>

					<description><![CDATA[报错代码： 或者： 或者： 分析： /etc/authselect/system-auth 文件或 /etc/authselect/password-auth 文件是不应该被手动修改的，如果被手动修改了，再使用 authselect select sssd 命令或者 authselect apply-changes 命令时则会有此类报错 解决方法： （注意：此方法会刷新 /etc/authselect/system-auth 文件和 /etc/authselect/password-auth 文件里的所有内容）]]></description>
										<content:encoded><![CDATA[
<h2>报错代码：</h2>



<pre class="wp-block-code"><code>&#91;error] &#91;/etc/authselect/system-auth] has unexpected content!
&#91;error] &#91;/etc/authselect/password-auth] has unexpected content!
&#91;error] Unexpected changes to the configuration were detected.
&#91;error] Refusing to activate profile unless those changes are removed or overwrite is requested.</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>&#91;error] &#91;/etc/authselect/system-auth] has unexpected content!
&#91;error] Unexpected changes to the configuration were detected.
&#91;error] Refusing to activate profile unless those changes are removed or overwrite is requested.</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>&#91;error] &#91;/etc/authselect/password-auth] has unexpected content!
&#91;error] Unexpected changes to the configuration were detected.
&#91;error] Refusing to activate profile unless those changes are removed or overwrite is requested.</code></pre>



<h2>分析：</h2>



<p>/etc/authselect/system-auth 文件或 /etc/authselect/password-auth 文件是不应该被手动修改的，如果被手动修改了，再使用 authselect select sssd 命令或者 authselect apply-changes 命令时则会有此类报错</p>



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



<pre class="wp-block-code"><code># authselect apply-changes</code></pre>



<p>（注意：此方法会刷新 /etc/authselect/system-auth 文件和 /etc/authselect/password-auth 文件里的所有内容）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 用户登录相关日志</title>
		<link>https://eternalcenter-may-1-2022.github.io/login-log/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 12 Feb 2022 15:49:11 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System General Log (系统普通日志)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=21918</guid>

					<description><![CDATA[内容一：所有正在登录的用户 内容二：所有的登录和登出记录 内容三：所有用户最有一次登录记录 内容四：所有错误登录尝试记录 内容五：所有信息 （其中也包括登录相关的记录）]]></description>
										<content:encoded><![CDATA[
<h4 id="内容一-所有正在登录的用户">内容一：所有正在登录的用户</h4>



<pre class="wp-block-code"><code>/var/run/utmp</code></pre>



<h4 id="内容二-所有的登录和登出记录">内容二：所有的登录和登出记录</h4>



<pre class="wp-block-code"><code>/var/log/wtmp</code></pre>



<h4 id="内容三-所有用户最有一次登录记录">内容三：所有用户最有一次登录记录</h4>



<pre class="wp-block-code"><code>/var/log/lastlog</code></pre>



<h4 id="内容四-所有错误登录尝试记录">内容四：所有错误登录尝试记录</h4>



<pre class="wp-block-code"><code>/var/log/btmp</code></pre>



<h4 id="内容五-所有信息-其中也包括登录相关的记录">内容五：所有信息 （其中也包括登录相关的记录）</h4>



<pre class="wp-block-code"><code>/var/log/messages</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] sudo 提权的实现 （sudo 提权的同时可以使用代理） （openSUSE &#038; SLE）</title>
		<link>https://eternalcenter-may-1-2022.github.io/sudo-self-proxy-opensuse-sle/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 15 Jan 2022 14:47:45 +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-may-1-2022.github.io/?p=21217</guid>

					<description><![CDATA[步骤一：给用户添加相应的 sudo 权限 添加以下内容： （补充：这里以给用户 zhumingyu 添加 /usr/bin/mysql 命令为例） 步骤二：设置用户使用自己的密码实现 sudo 提权 在 这一行下面添加： （补充：这里以允许用户在进行 sudo 提权的同时也能使用 http_proxy、https_proxy 为例）]]></description>
										<content:encoded><![CDATA[
<h4>步骤一：给用户添加相应的 sudo 权限</h4>



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



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



<pre class="wp-block-code"><code>……
zhumingyu ALL=(ALL) /usr/bin/mysql</code></pre>



<p>（补充：这里以给用户 zhumingyu 添加 /usr/bin/mysql 命令为例）</p>



<h4>步骤二：设置用户使用自己的密码实现 sudo 提权</h4>



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



<p>在</p>



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



<p>这一行下面添加：</p>



<pre class="wp-block-code"><code>......
Defaults env_keep += "http_proxy https_proxy"
......</code></pre>



<p>（补充：这里以允许用户在进行 sudo 提权的同时也能使用 http_proxy、https_proxy 为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 本地和 SSH 输错密码次数的限制 （pam_faillock 版） （CentOS Linux 8 &#038; RHEL 8 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/local-ssh-login-attempt-pam_faillock-centos-linux-8-rhel-8/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sun, 02 Jan 2022 08:34:31 +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-may-1-2022.github.io/?p=21068</guid>

					<description><![CDATA[步骤目录： 步骤一：背景了解 步骤二：设置 SSH 的登录限制2.1 在 sshd 中开启 UsePAM2.1.1 修改 sshd 的配置文件2.1.2 让修改的 sshd 配置文件生效2.2 确保 /etc/pam.d/login 包含 password-auth2.3 添加 pam_faillock 模块 步骤三：远程登录密码输错次数的用户管理3.1 显示某个用户近期输错了几次密码3.2 重制所有远程登录密码输错次数 具体的操作步骤： 步骤一：背景了解 从 CentOS Linux 8 &#38; RHEL 8 开始，系统的身份验证模块从 CentOS Linux 7 &#38; RHEL 7 的 pam_tally2 换成了 pam_faillock 步骤二：设置 SSH 的登录限制2.1 在 sshd 中开启 UsePAM2.1.1 修改 sshd 的配置文件 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/local-ssh-login-attempt-pam_faillock-centos-linux-8-rhel-8/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] Linux 本地和 SSH 输错密码次数的限制 （pam_faillock 版） （CentOS Linux 8 &#038; RHEL 8 版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2 id="步骤目录">步骤目录：</h2>



<h4 id="步骤一-背景了解">步骤一：背景了解</h4>



<h4 id="步骤二-设置-ssh-的登录限制-2-1-在-sshd-中开启-usepam-2-1-1-修改-sshd-配置文件-2-1-2-让-sshd-的配置生效-2-2-确保-etc-pam-d-login-包含-password-auth-2-3-添加-pam-faillock-模块">步骤二：设置 SSH 的登录限制<br>2.1 在 sshd 中开启 UsePAM<br>2.1.1 修改 sshd 的配置文件<br>2.1.2 让修改的 sshd 配置文件生效<br>2.2 确保 /etc/pam.d/login 包含 password-auth<br>2.3 添加 pam_faillock 模块</h4>



<h4 id="步骤三-远程登录密码输错次数的用户管理-3-1-显示某个用户近期输错了几次密码-3-2-重制所有远程登录密码输错次数">步骤三：远程登录密码输错次数的用户管理<br>3.1 显示某个用户近期输错了几次密码<br>3.2 重制所有远程登录密码输错次数</h4>



<h2 id="具体的操作步骤">具体的操作步骤：</h2>



<h4 id="步骤一-背景了解">步骤一：背景了解</h4>



<p>从 CentOS Linux 8 &amp; RHEL 8 开始，系统的身份验证模块从 CentOS Linux 7 &amp; RHEL 7 的 pam_tally2 换成了 pam_faillock</p>



<h4 id="步骤二-设置-ssh-的登录限制-2-1-在-sshd-中开启-usepam-2-1-1-修改-sshd-配置文件">步骤二：设置 SSH 的登录限制<br>2.1 在 sshd 中开启 UsePAM<br>2.1.1 修改 sshd 的配置文件</h4>



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



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
#UsePAM no
......</code></pre>



<p>修改为：</p>



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



<h4 id="2-1-2-让-sshd-的配置生效">2.1.2 让修改的 sshd 配置文件生效</h4>



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



<h4 id="2-2-确保-etc-pam-d-login-包含-password-auth">2.2 确保 /etc/pam.d/login 包含 password-auth</h4>



<pre class="wp-block-code"><code># cat /etc/pam.d/login | grep password-auth
auth       substack     password-auth
account    include      password-auth
password   include      password-auth
session    include      password-auth</code></pre>



<p>（注意：如果输出结果中不包含这 4 条内容则需要手动添加）</p>



<h4 id="2-3-添加-pam-faillock-模块">2.3 添加 pam_faillock 模块</h4>



<pre class="wp-block-code"><code># vim /etc/pam.d/password-auth</code></pre>



<p>在</p>



<pre class="wp-block-code"><code>......
auth required pam_env.so
......</code></pre>



<p>这一行下面添加：</p>



<pre class="wp-block-code"><code>......
auth  required  pam_faillock.so preauth silent audit even_deny_root deny=6 unlock_time=180
......</code></pre>



<p>在</p>



<pre class="wp-block-code"><code>auth sufficient pam_unix.so try_first_pass nullok</code></pre>



<p>这一行下面添加：</p>



<pre class="wp-block-code"><code>......
auth  &#91;default=die] pam_faillock.so authfail audit even_deny_root deny=6 unlock_time=180
......</code></pre>



<p>在</p>



<pre class="wp-block-code"><code>account required pam_unix.so</code></pre>



<p>这一行下面添加：</p>



<pre class="wp-block-code"><code>......
account required pam_faillock.so
......</code></pre>



<p>（补充：这里以包括 root 用户每使用密码 ssh 远程登录失败 6 次则被锁定 180 秒为例）</p>



<h4 id="步骤三-远程登录密码输错次数的用户管理-3-1-显示某个用户近期输错了几次密码">步骤三：远程登录密码输错次数的用户管理<br>3.1 显示某个用户近期输错了几次密码</h4>



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



<p>（补充：这里以显示 root 用户近期输错了几次密码为例）</p>



<h4 id="3-2-重制所有登录密码输错次数">3.2 重制所有登录密码输错次数</h4>



<pre class="wp-block-code"><code># faillock --reset</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 本地和 SSH 输错密码次数的限制 （pam_faillock 版） （authselect 版） （CentOS Linux 8 &#038; RHEL 8 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/ssh-attempt-pam_faillock-authselect-centos-linux-8-rhel-8/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 01 Jan 2022 14:04:37 +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>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=20768</guid>

					<description><![CDATA[步骤目录： 步骤一：了解背景 步骤二：设置 SSH 的登录限制2.1 在 sshd 中开启 UsePAM2.1.1 修改 sshd 的配置文件2.1.2 让修改的 sshd 配置文件生效2.2 确保 /etc/pam.d/sshd 包含 password-auth 步骤三：检查是否选择了 authselect 自定义认证 步骤四：配置认证4.1 如果 authselect 自定义认证存在4.1.1 修改 system-auth 文件4.1.2 修改 password-auth 文件4.2 如果 authselect 自定义认证不存在4.2.1 生成新的自定义认证4.2.1.1 备份当前的自定义认证4.2.1.2 创建新的自定义认证4.2.1.3 选择自定义认证4.2.1.4 显示当前选择的自定义认证4.2 修改自定义认证4.2.1 修改 system-auth 文件4.2.2 修改 password-auth 文件 步骤五：让配置的认证生效 步骤六：管理远程登录密码输错次数的用户6.1 显示某个用户近期输错了几次密码6.2 重制所有远程登录密码输错次数 具体的操作步骤： 步骤一：了解背景 从 CentOS &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/ssh-attempt-pam_faillock-authselect-centos-linux-8-rhel-8/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] Linux 本地和 SSH 输错密码次数的限制 （pam_faillock 版） （authselect 版） （CentOS Linux 8 &#038; RHEL 8 版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2 id="步骤目录">步骤目录：</h2>



<h4 id="步骤一-背景了解">步骤一：了解背景</h4>



<h4 id="步骤二-设置-ssh-的登录限制-2-1-在-sshd-中开启-usepam-2-1-1-修改-sshd-配置文件-2-1-2-让-sshd-的配置生效-2-2-确保-etc-pam-d-sshd-包含-password-auth">步骤二：设置 SSH 的登录限制<br>2.1 在 sshd 中开启 UsePAM<br>2.1.1 修改 sshd 的配置文件<br>2.1.2 让修改的 sshd 配置文件生效<br>2.2 确保 /etc/pam.d/sshd 包含 password-auth</h4>



<h4 id="步骤三-检查是否选择了-authselect-自定义认证">步骤三：检查是否选择了  authselect  自定义认证</h4>



<h4>步骤四：配置认证<br>4.1 如果 authselect 自定义认证存在<br>4.1.1 修改 system-auth 文件<br>4.1.2 修改 password-auth 文件<br>4.2 如果 authselect 自定义认证不存在<br>4.2.1 生成新的自定义认证<br>4.2.1.1 备份当前的自定义认证<br>4.2.1.2 创建新的自定义认证<br>4.2.1.3 选择自定义认证<br>4.2.1.4 显示当前选择的自定义认证<br>4.2 修改自定义认证<br>4.2.1 修改 system-auth 文件<br>4.2.2 修改 password-auth 文件</h4>



<h4 id="步骤五-让配置的认证生效">步骤五：让配置的认证生效</h4>



<h4 id="步骤六-远程登录密码输错次数的用户管理-6-1-显示某个用户近期输错了几次密码-6-2-重制所有远程登录密码输错次数">步骤六：管理远程登录密码输错次数的用户<br>6.1 显示某个用户近期输错了几次密码<br>6.2 重制所有远程登录密码输错次数</h4>



<h2 id="具体的操作步骤">具体的操作步骤：</h2>



<h4 id="步骤一-背景了解">步骤一：了解背景</h4>



<p>从 CentOS Linux 8 &amp; RHEL 8 开始，系统的身份验证模块从 CentOS Linux 7 &amp; RHEL 7 的 pam_tally2 换成了 pam_faillock</p>



<h4 id="步骤二-设置-ssh-的登录限制-2-1-在-sshd-中开启-usepam-2-1-1-修改-sshd-配置文件">步骤二：设置 SSHd 的登录限制<br>2.1 在 sshd 中开启 UsePAM<br>2.1.1 修改 sshd 的配置文件</h4>



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



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
#UsePAM no
......</code></pre>



<p>修改为：</p>



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



<h4 id="2-1-2-让-sshd-的配置生效">2.1.2 让修改 sshd 配置文件生效</h4>



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



<h4 id="2-2-确保-etc-pam-d-sshd-包含-password-auth">2.2 确保 /etc/pam.d/sshd 包含 password-auth</h4>



<pre class="wp-block-code"><code># cat /etc/pam.d/sshd | grep password-auth
auth       substack     password-auth
account    include      password-auth
password   include      password-auth
session    include      password-auth</code></pre>



<p>（注意：如果输出结果中不包含这 4 条内容则需要手动添加）</p>



<h4 id="步骤三-检查是否选择了-authselect-自定义认证">步骤三：检查是否选择了  authselect  自定义认证</h4>



<pre class="wp-block-code"><code># authselect current | awk 'NR == 1 {print $3}' | grep custom/
custom/password-policy</code></pre>



<p>（<br>补充：<br>（1）如果这条命令里没有输出则代表没有选择自定义认证<br>（2）从这里的输出结果可以看出这里选择的自定义认证是 custom/password-policy<br>）</p>



<h4 id="步骤四-配置认证-4-1-如果-authselect-自定义认证存在-4-1-1-修改-system-auth-文件">步骤四：配置认证<br>4.1 如果  authselect  自定义认证存在<br>4.1.1 修改 system-auth 文件</h4>



<pre class="wp-block-code"><code># vim /etc/authselect/custom/password-policy/system-auth</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......</code></pre>



<p>（补充：这里以包括 root 用户每使用密码 ssh 远程登录失败 6 次则被锁定 180 秒为例）</p>



<h4 id="4-1-2-修改-password-auth-文件"> 4.1.2 修改 password-auth 文件 </h4>



<pre class="wp-block-code"><code># vim /etc/authselect/custom/password-policy/password-auth</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......

修改为：
......
auth        required                                     pam_faillock.so preauth silent audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......</code></pre>



<p>（补充：这里以包括 root 用户每使用密码 ssh 远程登录失败 6 次则被锁定 180 秒为例）</p>



<h4>4.2 如果 authselect 自定义认证不存在<br>4.2.1 生成新的自定义认证<br>4.2.1.1 备份当前的自定义认证</h4>



<pre class="wp-block-code"><code># authselect apply-changes -b --backup=sssd.backup</code></pre>



<p>（补充：这里以创建 sssd.backup 备份文件为例）</p>



<h4>4.2.1.2 创建新的自定义认证</h4>



<pre class="wp-block-code"><code># authselect create-profile password-policy -b sssd --symlink-meta --symlink-pam</code></pre>



<p>（补充：这里以生成名为 password-policy 的自定义认证为例）</p>



<h4>4.2.1.3 选择自定义认证</h4>



<pre class="wp-block-code"><code># authselect select custom/password-policy with-sudo with-faillock without-nullok with-mkhomedir</code></pre>



<p>（<br>补充：<br>1) 这里以选择名为 password-policy 的自定义认证为例<br>2) 这里设置了 with-sudo、with-faillock、without-nullok 和 with-mkhomedir 参数<br>）</p>



<h4>4.2.1.4 显示当前选择的自定义认证</h4>



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



<p>（补充：这里以生成并选择名为 password-policy 的自定义认证为例）</p>



<h4 id="4-2-如果-authselect-自定义认证不存在-4-2-1-修改-system-auth-文件">4.2 修改自定义认证<br>4.2.1 修改 system-auth 文件</h4>



<pre class="wp-block-code"><code># vim /etc/authselect/custom/password-policy/password-auth</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......</code></pre>



<p>（补充：这里以包括 root 用户每使用密码 ssh 远程登录失败 6 次则被锁定 180 秒为例）</p>



<h4 id="4-2-2-修改-password-auth-文件">4.2.2 修改 password-auth 文件</h4>



<pre class="wp-block-code"><code># vim /etc/authselect/custom/password-policy/password-auth</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail                               {include if "with-faillock"}
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
auth        required                                     pam_faillock.so preauth silent audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......
auth        required                                     pam_faillock.so authfail audit even_deny_root deny=6 unlock_time=180                               {include if "with-faillock"}
......</code></pre>



<p>（补充：这里以包括 root 用户每使用密码 ssh 远程登录失败 6 次则被锁定 180 秒为例）</p>



<h4 id="步骤五-让配置的认证生效">步骤五：让配置的认证生效</h4>



<pre class="wp-block-code"><code># authselect apply-changes</code></pre>



<p>（注意：此步骤会刷新 /etc/authselect/system-auth 文件和 /etc/authselect/password-auth 文件）</p>



<h4 id="步骤六-远程登录密码输错次数的用户管理-6-1-显示某个用户近期输错了几次密码">步骤六：管理远程登录密码输错次数的用户<br>6.1 显示某个用户近期输错了几次密码</h4>



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



<p>（补充：这里以显示 root 用户近期输错了几次密码为例）</p>



<h4 id="6-2-重制所有远程登录密码输错次数">6.2 重制所有远程登录密码输错次数</h4>



<pre class="wp-block-code"><code># faillock --reset</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 SSH （远程登录）</title>
		<link>https://eternalcenter-may-1-2022.github.io/ssh/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 26 Nov 2021 15:56:06 +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 (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=19146</guid>

					<description><![CDATA[案例一：脚本中常用的方式 （补充：这里以1) 安静模式2) 打开新端口的模式3) 不检查服务器记录4) 超时时间为 5 秒5) 通过 eternalcenter 用户6) 登录 eternalcenter.com 服务器为例） 案例二：在操作中常用的方式 （补充：这里以1) 带图形的模式2) 通过 eternalcenter 用户3) 登录 eternalcenter.com 服务器为例）]]></description>
										<content:encoded><![CDATA[
<h2>案例一：脚本中常用的方式</h2>



<pre class="wp-block-code"><code># ssh -q -t -t -o StrictHostKeyChecking=no -o ConnectTimeout=5 -l eternalcenter eternalcenter.com</code></pre>



<p>（<br>补充：这里以<br>1) 安静模式<br>2) 打开新端口的模式<br>3) 不检查服务器记录<br>4) 超时时间为 5 秒<br>5) 通过 eternalcenter 用户<br>6) 登录 eternalcenter.com 服务器<br>为例<br>）</p>



<h2>案例二：在操作中常用的方式</h2>



<pre class="wp-block-code"><code># ssh -X eternalcenter@eternalcenter.com</code></pre>



<p>（<br>补充：这里以<br>1) 带图形的模式<br>2) 通过 eternalcenter 用户<br>3) 登录 eternalcenter.com 服务器<br>为例<br>）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 批量修改多个远程服务器某一个用户的密码 （精致版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/shell-password-change-refined-version/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sun, 10 Oct 2021 13:08:50 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Languages (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Deployment (部署)]]></category>
		<category><![CDATA[Shell Others (其他)]]></category>
		<category><![CDATA[Shell Tool (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=18100</guid>

					<description><![CDATA[介绍： 作者：朱明宇名称：批量修改多个远程服务器某一个用户的密码作用：批量修改多个远程服务器某一个用户的密码 使用方法：1. 将此脚本和清单 $list 文件放在同一目录下2. 清单 $list 里每服务器名占用一行3. 给脚本分割线里的变量赋值4. 给此脚本添加执行权限5. 执行此脚本 脚本分割线里的变量：1. list=”list.txt” #指定清单的目录和名称2. user=eternalcenter #指定要修改密码的用户3. password=eternalcenter #指定要修改的密码 注意：此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限 脚本：]]></description>
										<content:encoded><![CDATA[
<h2>介绍：</h2>



<p>作者：朱明宇<br>名称：批量修改多个远程服务器某一个用户的密码<br>作用：批量修改多个远程服务器某一个用户的密码</p>



<p>使用方法：<br>1. 将此脚本和清单 $list 文件放在同一目录下<br>2. 清单 $list 里每服务器名占用一行<br>3. 给脚本分割线里的变量赋值<br>4. 给此脚本添加执行权限<br>5. 执行此脚本</p>



<p>脚本分割线里的变量：<br>1. list=”list.txt” #指定清单的目录和名称<br>2. user=eternalcenter #指定要修改密码的用户<br>3. password=eternalcenter #指定要修改的密码</p>



<p>注意：<br>此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限</p>



<h2>脚本：</h2>



<pre class="wp-block-code"><code>#!/bin/bash

####################### Separator ########################

list="list.txt"
user=eternalcenter
password=eternalcenter

####################### Separator ########################

num=1

cat $list
for i in `cat $list`
do
        echo $num
        echo $i

	ssh -t $i "type lsb_release" &amp;> /dev/null
        if &#91; $? -ne 0 ]; then
              distribution=`ssh -t $i "cat /etc/*release | grep '^NAME'"`
	      if &#91; $? -ne 0 ];then
		      distribution=`ssh -t $i "cat /etc/*release"`
	      fi
        else
              distribution=`ssh -t $i "lsb_release -i | grep 'ID' | grep -v 'n/a'"`
        fi;

        echo $distribution

	case $distribution in
		*"RedHat"* | *"Red Hat"*)
		ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*"CentOS"*)
		ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*"SUSE"* | *"SLES"*)
		ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;
               
		*"openSUSE"*)
		ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*)
                echo -e "\033&#91;31m$i is fail \033&#91;0m" 
		;;
        esac

        let num++

        echo
done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] nftables 防火墙的使用 （永久版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/nfttables-permanent/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 03 Aug 2021 06:28:03 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Firewall (系统防火墙)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=17232</guid>

					<description><![CDATA[注意： 只有 CentOS 8 &#38; RHEL 8 才可以使用 nftables 防火墙 正文： 步骤目录： 步骤一：从 firewalld 防火墙切换至 nftables 防火墙1.1 安装 nftables 防火墙1.2 清空 iptables 防火墙的策略表1.2.1 清空 ipv4 iptables 防火墙的策略表1.2.2 清空 ipv6 iptables 防火墙的策略表1.3 停止使用 firewalld 防火墙1.3.1 取消 firewalld 防火墙开机自启1.3.2 停止 firewalld 防火墙1.4 启用 nftables 防火墙1.4.1 开机自启 nftables 防火墙1.4.2 启动 nftables 防火墙 步骤二：创建永久的 nftales 防火墙的策略表并条件永久的 nftables 防火墙策略2.1 在 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/nfttables-permanent/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] nftables 防火墙的使用 （永久版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2>注意：</h2>



<p>只有 CentOS 8 &amp; RHEL 8 才可以使用 nftables 防火墙</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2>正文：</h2>



<h2>步骤目录：</h2>



<h4>步骤一：从 firewalld 防火墙切换至 nftables 防火墙<br>1.1 安装 nftables 防火墙<br>1.2 清空 iptables 防火墙的策略表<br>1.2.1 清空 ipv4 iptables 防火墙的策略表<br>1.2.2 清空 ipv6 iptables 防火墙的策略表<br>1.3 停止使用 firewalld 防火墙<br>1.3.1 取消 firewalld 防火墙开机自启<br>1.3.2 停止 firewalld 防火墙<br>1.4 启用 nftables 防火墙<br>1.4.1 开机自启 nftables 防火墙<br>1.4.2 启动 nftables 防火墙</h4>



<h4>步骤二：创建永久的 nftales 防火墙的策略表并条件永久的 nftables 防火墙策略<br>2.1 在 nftables 防火墙的配置文件中添加 nftables 防火墙策略文件<br>2.2 在 nftables 防火墙策略文件中添加 nftables 防火墙策略</h4>



<h2>具体的操作步骤：</h2>



<h4>步骤一：从 firewalld 防火墙切换至 nftables 防火墙<br>1.1 安装 nftables 防火墙</h4>



<pre class="wp-block-code"><code># dnf install nftables</code></pre>



<h4>1.2 清空 iptables 防火墙的策略表<br>1.2.1 清空 ipv4 iptables 防火墙的策略表</h4>



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



<h4>1.2.2 清空 ipv6 iptables 防火墙的策略表</h4>



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



<h4>1.3 停止使用 firewalld 防火墙<br>1.3.1 取消 firewalld 防火墙开机自启</h4>



<pre class="wp-block-code"><code># systemctl disable firewalld.service</code></pre>



<h4>1.3.2 停止 firewalld 防火墙</h4>



<pre class="wp-block-code"><code># systemctl stop firewalld.service</code></pre>



<h4>1.4 启用 nftables 防火墙<br>1.4.1 开机自启 nftables 防火墙</h4>



<pre class="wp-block-code"><code># systemctl enable nftables</code></pre>



<h4>1.4.2 启动 nftables 防火墙</h4>



<pre class="wp-block-code"><code># systemctl start nftables</code></pre>



<h4>步骤二：创建永久的 nftales 防火墙的策略表并条件永久的 nftables 防火墙策略<br>2.1 在 nftables 防火墙的配置文件中添加 nftables 防火墙策略文件</h4>



<pre class="wp-block-code"><code># vi /etc/sysconfig/nftables.conf</code></pre>



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



<pre class="wp-block-code"><code>......
include "/etc/nftables/nftables.rules"</code></pre>



<h4>2.2 在 nftables 防火墙策略文件中添加 nftables 防火墙策略</h4>



<pre class="wp-block-code"><code># vi /etc/nftables/nftables.rules
flush ruleset
table inet siemens_FW {
    chain siemens_FW_input {
      type filter hook input priority 0; policy accept;
      iif "lo" accept
      ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop
      ip6 saddr ::1 counter packets 0 bytes 0 drop
      ip saddr 192.168.1.1 tcp dport ssh accept                  
      tcp dport ssh drop
    }
    chain siemens_FW_forward {
      type filter hook forward priority 0; policy accept;
    } 
    chain siemens_FW_output {
      type filter hook output priority 0; policy accept;
    }
}</code></pre>



<p>（<br>补充：<br>（1）这里以基本的本地巡回路由策略并禁止除 192.168.1.1 的 IP 地址访问本地的 22 端口为例<br>（2）这里的 /etc/nftables/nftables.rules 是在 2.1 中添加的<br>）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] nftables 防火墙的使用 （临时版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/nfttables-temporary/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 03 Aug 2021 06:19:08 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Firewall (系统防火墙)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=17229</guid>

					<description><![CDATA[注意： 只有 CentOS 8 &#38; RHEL 8 才可以使用 nftables 防火墙 正文： 步骤目录： 步骤一：从 firewalld 防火墙切换至 nftables 防火墙1.1 安装 nftables 防火墙1.2 清空 iptables 防火墙的策略表1.2.1 清空 ipv4 iptables 防火墙的策略表1.2.2 清空 ipv6 iptables 防火墙的策略表1.3 停止使用 firewalld 防火墙1.3.1 取消 firewalld 防火墙开机自启1.3.2 停止 firewalld 防火墙1.4 启用 nftables 防火墙1.4.1 开机自启 nftables 防火墙1.4.2 启动 nftables 防火墙 步骤二：创建 nftables 防火墙的策略表2.1 创建 nftables 防火墙的策略表2.2 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/nfttables-temporary/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] nftables 防火墙的使用 （临时版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2>注意：</h2>



<p>只有 CentOS 8 &amp; RHEL 8 才可以使用 nftables 防火墙</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2>正文：</h2>



<h2>步骤目录：</h2>



<h4>步骤一：从 firewalld 防火墙切换至 nftables 防火墙<br>1.1 安装 nftables 防火墙<br>1.2 清空 iptables 防火墙的策略表<br>1.2.1 清空 ipv4 iptables 防火墙的策略表<br>1.2.2 清空 ipv6 iptables 防火墙的策略表<br>1.3 停止使用 firewalld 防火墙<br>1.3.1 取消 firewalld 防火墙开机自启<br>1.3.2 停止 firewalld 防火墙<br>1.4 启用 nftables 防火墙<br>1.4.1 开机自启 nftables 防火墙<br>1.4.2 启动 nftables 防火墙</h4>



<h4>步骤二：创建 nftables 防火墙的策略表<br>2.1 创建 nftables 防火墙的策略表<br>2.2 创建 nftables 防火墙的策略表的 input 链<br>2.3 创建 nftables 防火墙的策略表的 forward 链<br>2.4 创建 nftables 防火墙的策略表的 output 链</h4>



<h4>步骤三：添加临时基本的本地巡回路由策略</h4>



<h2>具体的操作步骤：</h2>



<h4>步骤一：从 firewalld 防火墙切换至 nftables 防火墙<br>1.1 安装 nftables 防火墙</h4>



<pre class="wp-block-code"><code># dnf install nftables</code></pre>



<h4>1.2 清空 iptables 防火墙的策略表<br>1.2.1 清空 ipv4 iptables 防火墙的策略表</h4>



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



<h4>1.2.2 清空 ipv6 iptables 防火墙的策略表</h4>



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



<h4>1.3 停止使用 firewalld 防火墙<br>1.3.1 取消 firewalld 防火墙开机自启</h4>



<pre class="wp-block-code"><code># systemctl disable firewalld.service</code></pre>



<h4>1.3.2 停止 firewalld 防火墙</h4>



<pre class="wp-block-code"><code># systemctl stop firewalld.service</code></pre>



<h4>1.4 启用 nftables 防火墙<br>1.4.1 开机自启 nftables 防火墙</h4>



<pre class="wp-block-code"><code># systemctl enable nftables</code></pre>



<h4>1.4.2 启动 nftables 防火墙</h4>



<pre class="wp-block-code"><code># systemctl start nftables</code></pre>



<h4>步骤二：创建 nftables 防火墙的策略表<br>2.1 创建 nftables 防火墙的策略表</h4>



<pre class="wp-block-code"><code># nft create table inet &lt;tablename&gt;</code></pre>



<h4>2.2 创建 nftables 防火墙的策略表的 input 链</h4>



<pre class="wp-block-code"><code># nft create chain inet &lt;tablename&gt; input { type filter hook input priority 0 \; }</code></pre>



<h4>2.3 创建 nftables 防火墙的策略表的 forward 链</h4>



<pre class="wp-block-code"><code># nft create chain inet &lt;tablename&gt; forward { type filter hook forward priority 0 \; }</code></pre>



<h4>2.4 创建 nftables 防火墙的策略表的 output 链</h4>



<pre class="wp-block-code"><code># nft create chain inet &lt;tablename&gt; output { type filter hook output priority 0 \; }</code></pre>



<h4>步骤三：添加临时基本的本地巡回路由策略</h4>



<pre class="wp-block-code"><code># nft add rule inet filter input iif lo accept
# nft add rule inet filter input ip saddr 127.0.0.0/8 counter drop
# nft add rule inet filter input ip6 saddr ::1 counter drop</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 批量修改多个远程服务器某一个用户的密码 （简单版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/shell-password-change-simple-version/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 09 Jun 2021 10:37:59 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Languages (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Deployment (部署)]]></category>
		<category><![CDATA[Shell Others (其他)]]></category>
		<category><![CDATA[Shell Tool (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=14638</guid>

					<description><![CDATA[介绍： 作者：朱明宇名称：批量修改多个远程服务器某一个用户的密码作用：批量修改多个远程服务器某一个用户的密码，并显示密码更新时间 使用方法：1. 将此脚本和清单 $list 文件放在同一目录下2. 清单 $list 里每服务器名占用一行3. 给脚本分割线里的变量赋值4. 给此脚本添加执行权限5. 执行此脚本 脚本分割线里的变量：1. list=&#8221;list.txt&#8221; #指定清单的目录和名称2. user=eternalcenter #指定要修改密码的用户3. password=eternalcenter #指定要修改的密码 注意：此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限 脚本：]]></description>
										<content:encoded><![CDATA[
<h2 id="介绍">介绍：</h2>



<p>作者：朱明宇<br>名称：批量修改多个远程服务器某一个用户的密码<br>作用：批量修改多个远程服务器某一个用户的密码，并显示密码更新时间</p>



<p>使用方法：<br>1. 将此脚本和清单 $list 文件放在同一目录下<br>2. 清单 $list 里每服务器名占用一行<br>3. 给脚本分割线里的变量赋值<br>4. 给此脚本添加执行权限<br>5. 执行此脚本</p>



<p>脚本分割线里的变量：<br>1. list=&#8221;list.txt&#8221; #指定清单的目录和名称<br>2. user=eternalcenter #指定要修改密码的用户<br>3. password=eternalcenter #指定要修改的密码</p>



<p>注意：<br>此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限</p>



<h2 id="脚本">脚本：</h2>



<pre class="wp-block-code"><code>#!/bin/bash

####################### Separator ########################

list="list.txt"
user=eternalcenter
password=eternalcenter

####################### Separator ########################

num=1

cat $list
for i in `cat $list`
do
        echo $num
        echo $i
        ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
        ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
        ssh -t $i sudo -u root su - root -c \"chage -l $user\"
        let num++

        echo
done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux SSH 登陆提示信息的修改</title>
		<link>https://eternalcenter-may-1-2022.github.io/banner-ssh/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 11 May 2021 09:17:51 +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-may-1-2022.github.io/?p=14227</guid>

					<description><![CDATA[步骤一：修改 sshd 的配置文件 将以下内容： 修改为： 或者： （补充：这里以将 ssh 登陆提示信息修改为 eternalcenter 为例） 步骤二：重启 sshd 服务]]></description>
										<content:encoded><![CDATA[
<h4>步骤一：修改 sshd 的配置文件</h4>



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



<p>将以下内容：</p>



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



<p>修改为：</p>



<pre class="wp-block-code"><code>Banner eternalcenter</code></pre>



<p>或者：</p>



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



<p>（补充：这里以将 ssh 登陆提示信息修改为 eternalcenter 为例）</p>



<h4>步骤二：重启 sshd 服务</h4>



<pre class="wp-block-code"><code># systemctl restart sshd</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 本地登陆提示信息的修改 （openSUSE &#038; SLE 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/banner-local-opensuse-sle/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 11 May 2021 03:26:28 +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-may-1-2022.github.io/?p=14223</guid>

					<description><![CDATA[内容目录： 内容一：openSUSE 15.0、openSUSE 15.1、openSUSE 15.2 和 SLE12.X 修改本地登陆提示信息 内容二：openSUSE 15.3 及以上版本修改本地登陆提示信息2.1 修改本地登陆系统方面的提示信息2.2 去除本地登陆网卡方面的提示信息2.2.1 去除现有的网卡提示信息2.2.2 设置不再新生成网卡提示信息2.2.3 追加本地登陆提示信息 内容三：SLE 15.X 修改本地登陆提示信息3.1 修改本地登陆系统方面的提示信息3.2 去除本地登陆网卡方面的提示信息3.2.1 去除现有的网卡提示信息3.2.2 设置不再新生成网卡提示信息3.2.3 设置不再新生成网卡提示信息 具体的内容： 内容一：openSUSE 15.0、openSUSE 15.1、openSUSE 15.2 和 SLE 12.X 修改本地登陆提示信息 （补充：这里以将本地登陆提示信息修改为 eternalcenter.com 为例） 内容二：openSUSE 15.3 及以上版本修改本地登陆提示信息2.1 修改本地登陆系统方面的提示信息 2.2 去除本地登陆网卡方面的提示信息2.2.1 去除现有的网卡提示信息 2.2.2 设置不再新生成网卡提示信息 将以下内容： 修改为： 或者： （补充：1) 这里以将本地登陆提示信息修改为 eternalcenter.com 为例2) 将 NETWORK_INTERFACE_REGEX=&#8221;^[be]&#8221; 修改为 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/banner-local-opensuse-sle/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux 本地登陆提示信息的修改 （openSUSE &#038; SLE 版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h2>内容目录：</h2>



<h4>内容一：openSUSE 15.0、openSUSE 15.1、openSUSE 15.2 和 SLE12.X 修改本地登陆提示信息</h4>



<h4>内容二：openSUSE 15.3 及以上版本修改本地登陆提示信息<br>2.1 修改本地登陆系统方面的提示信息<br>2.2 去除本地登陆网卡方面的提示信息<br>2.2.1 去除现有的网卡提示信息<br>2.2.2 设置不再新生成网卡提示信息<br>2.2.3 追加本地登陆提示信息</h4>



<h4>内容三：SLE 15.X 修改本地登陆提示信息<br>3.1 修改本地登陆系统方面的提示信息<br>3.2 去除本地登陆网卡方面的提示信息<br>3.2.1 去除现有的网卡提示信息<br>3.2.2 设置不再新生成网卡提示信息<br>3.2.3 设置不再新生成网卡提示信息</h4>



<h2>具体的内容：</h2>



<h4>内容一：openSUSE 15.0、openSUSE 15.1、openSUSE 15.2 和 SLE 12.X 修改本地登陆提示信息</h4>



<pre class="wp-block-code"><code># echo 'eternalcenter.com' &gt; /etc/issue
# echo 'eternalcenter.com' &gt; /etc/issue.net</code></pre>



<p>（补充：这里以将本地登陆提示信息修改为 eternalcenter.com 为例）</p>



<h4>内容二：openSUSE 15.3 及以上版本修改本地登陆提示信息<br>2.1 修改本地登陆系统方面的提示信息</h4>



<pre class="wp-block-code"><code># echo 'eternalcenter' &gt; /usr/lib/issue.d/10-openSUSE.conf</code></pre>



<h4>2.2 去除本地登陆网卡方面的提示信息<br>2.2.1 去除现有的网卡提示信息</h4>



<pre class="wp-block-code"><code># issue-generator network remove eth0</code></pre>



<h4>2.2.2 设置不再新生成网卡提示信息</h4>



<pre class="wp-block-code"><code># vim /etc/sysconfig/issue-generator</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
NETWORK_INTERFACE_REGEX="^&#91;be]"
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
NETWORK_INTERFACE_REGEX="^&#91;b]"
......</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># sed -i 's/NETWORK_INTERFACE_REGEX="^\&#91;be\]"/NETWORK_INTERFACE_REGEX="^\&#91;b\]"/' /etc/sysconfig/issue-generator</code></pre>



<p>（<br>补充：<br>1) 这里以将本地登陆提示信息修改为 eternalcenter.com 为例<br>2) 将 NETWORK_INTERFACE_REGEX=&#8221;^[be]&#8221; 修改为 NETWORK_INTERFACE_REGEX=&#8221;^[b]&#8221; 是不再显示网卡信息<br>）</p>



<h4>2.2.3 追加本地登陆提示信息</h4>



<pre class="wp-block-code"><code># echo 'Welcome' /etc/issue.d/issue</code></pre>



<p>（<br>补充：<br>1) 这里以添加 Welcome 本地登陆提示信息为例<br>2) 结合上文的案例，这里将同时显示 eternalcenter.com 和 Welcome<br>）</p>



<h4>内容三：SLE 15.X 修改本地登陆提示信息<br>3.1 修改本地登陆系统方面的提示信息</h4>



<pre class="wp-block-code"><code># echo 'eternalcenter' &gt; /usr/lib/issue.d/10-SUSE</code></pre>



<h4>3.2 去除本地登陆网卡方面的提示信息<br>3.2.1 去除现有的网卡提示信息</h4>



<pre class="wp-block-code"><code># issue-generator network remove eth0</code></pre>



<h4>3.2.2 设置不再新生成网卡提示信息</h4>



<pre class="wp-block-code"><code># vim /etc/sysconfig/issue-generator</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
NETWORK_INTERFACE_REGEX="^&#91;be]"
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
NETWORK_INTERFACE_REGEX="^&#91;b]"
......</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># sed -i 's/NETWORK_INTERFACE_REGEX="^\&#91;be\]"/NETWORK_INTERFACE_REGEX="^\&#91;b\]"/' /etc/sysconfig/issue-generator</code></pre>



<p>（<br>补充：<br>1) 这里以将本地登陆提示信息修改为 eternalcenter.com 为例<br>2) 将 NETWORK_INTERFACE_REGEX=”^[be]” 修改为 NETWORK_INTERFACE_REGEX=”^[b]” 是不再显示网卡信息<br>）</p>



<h4>3.2.3 追加本地登陆提示信息</h4>



<pre class="wp-block-code"><code># echo 'Welcome' /etc/issue.d/issue</code></pre>



<p>（<br>补充：<br>1) 这里以添加 Welcome 本地登陆提示信息为例<br>2) 结合上文的案例，这里将同时显示 eternalcenter.com 和 Welcome<br>）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 本地输错密码次数的限制 （pam_tally2.so 版） （openSUSE &#038; SLE &#038; CentOS Linux 7 &#038; RHEL 7 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/local-login-attempt-pam_tally2-so-opensuse-sle-centos-linux-7-rhel-7/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 20 Mar 2021 12:00:54 +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 Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=13629</guid>

					<description><![CDATA[步骤一：在 /etc/pam.d/login 文件中配置 pam_tally2.so 模块的相关参数 （补充：1) 这里的 pam_tally2.so 代表使用 pam_tally2.so 模块2) 这里的 deny=15 代表输错 15 次后会禁止登陆3) 这里的 unlock_time=3000 代表禁止登陆后 3000 毫秒后可以重新登陆4) 这里的 even_deny_root 代表 root 用户也包括在其中5）这里的 root_unlock_time=3000 代表禁止 root 用户登陆后 3000 毫秒后可以重新登陆） 步骤二：在 /etc/pam.d/sshd 文件中添加使用 pam_tally2.so 模块的参数 （补充：这里的 pam_tally2.so 代表加载 pam_tally2.so 模块） 步骤三：远程登录密码输错次数的用户管理3.1 显示某一个用户近期输错了几次密码 3.2 重制某一个用户登录密码输错次数]]></description>
										<content:encoded><![CDATA[
<h4 id="步骤一-在-etc-pam-d-login-文件中配置-pam-tally2-so-模块的相关参数">步骤一：在 /etc/pam.d/login 文件中配置 pam_tally2.so 模块的相关参数</h4>



<pre class="wp-block-code"><code># sed -i '/auth.*include.*common-auth/a auth      required   pam_tally2.so onerr=fail audit silent deny=15 unlock_time=3000 even_deny_root root_unlock_time=3000' /etc/pam.d/login</code></pre>



<p>（<br>补充：<br>1) 这里的 pam_tally2.so 代表使用 pam_tally2.so 模块<br>2) 这里的 deny=15 代表输错 15 次后会禁止登陆<br>3) 这里的 unlock_time=3000 代表禁止登陆后 3000 毫秒后可以重新登陆<br>4) 这里的 even_deny_root 代表 root 用户也包括在其中<br>5）这里的 root_unlock_time=3000 代表禁止 root 用户登陆后 3000 毫秒后可以重新登陆<br>）</p>



<h4 id="步骤二-在-etc-pam-d-sshd-文件中添加使用-pam-tally2-so-模块的参数">步骤二：在 /etc/pam.d/sshd 文件中添加使用 pam_tally2.so 模块的参数</h4>



<pre class="wp-block-code"><code># sed -i '/account.*include.*common-account/a account     required    pam_tally2.so' /etc/pam.d/login</code></pre>



<p>（补充：这里的 pam_tally2.so 代表加载 pam_tally2.so 模块）</p>



<h4 id="步骤三-远程登录密码输错次数的用户管理-3-1-查看某一个用户近期输错了几次密码">步骤三：远程登录密码输错次数的用户管理<br>3.1 显示某一个用户近期输错了几次密码</h4>



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



<h4 id="3-2-重制某一个用户登录密码输错次数">3.2 重制某一个用户登录密码输错次数</h4>



<pre class="wp-block-code"><code># pam_tally2 -u &lt;user&gt; -r --reset</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux SSH 输错密码次数的限制 （pam_tally2.so 版） （openSUSE &#038; SLE &#038; CentOS Linux 7 &#038; RHEL 7 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/ssh-attempt-pam_tally2-so-opensuse-sle-centos-linux-7-rhel-7/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 20 Mar 2021 11:54:51 +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-may-1-2022.github.io/?p=13618</guid>

					<description><![CDATA[步骤一：在 /etc/pam.d/sshd 文件中配置 pam_tally2.so 模块的相关参数 （补充：1) 这里的 pam_tally2.so 代表使用 pam_tally2.so 模块2) 这里的 deny=15 代表输错 15 次后会禁止登陆3) 这里的 unlock_time=3000 代表禁止登陆后 3000 毫秒后可以重新登陆4) 这里的 even_deny_root 代表 root 用户也包括在其中5）这里的 root_unlock_time=3000 代表禁止 root 用户登陆后 3000 毫秒后可以重新登陆） 步骤二：在 /etc/pam.d/sshd 文件中添加使用 pam_tally2.so 模块的参数 （补充：这里的 pam_tally2.so 代表加载 pam_tally2.so 模块） 步骤三：远程登录密码输错次数的用户管理3.1 查看某一个用户近期输错了几次密码 3.2 重制某一个用户登录密码输错次数]]></description>
										<content:encoded><![CDATA[
<h4 id="步骤一-在-etc-pam-d-sshd-文件中配置-pam-tally2-so-模块的相关参数">步骤一：在 /etc/pam.d/sshd 文件中配置 pam_tally2.so 模块的相关参数</h4>



<pre class="wp-block-code"><code># sed -i '/auth.*include.*common-auth/a auth        required    pam_tally2.so onerr=fail audit silent deny=15 unlock_time=3000 even_deny_root root_unlock_time=3000' /etc/pam.d/sshd</code></pre>



<p>（<br>补充：<br>1) 这里的 pam_tally2.so 代表使用 pam_tally2.so 模块<br>2) 这里的 deny=15 代表输错 15 次后会禁止登陆<br>3) 这里的 unlock_time=3000 代表禁止登陆后 3000 毫秒后可以重新登陆<br>4) 这里的 even_deny_root 代表 root 用户也包括在其中<br>5）这里的 root_unlock_time=3000 代表禁止 root 用户登陆后 3000 毫秒后可以重新登陆<br>）</p>



<h4 id="步骤二-在-etc-pam-d-sshd-文件中添加使用-pam-tally2-so-模块的参数">步骤二：在 /etc/pam.d/sshd 文件中添加使用 pam_tally2.so 模块的参数</h4>



<pre class="wp-block-code"><code># sed -i '/account.*include.*common-account/a account     required    pam_tally2.so' /etc/pam.d/sshd</code></pre>



<p>（补充：这里的 pam_tally2.so 代表加载 pam_tally2.so 模块）</p>



<h4 id="步骤三-远程登录密码输错次数的用户管理-3-1-查看某一个用户近期输错了几次密码">步骤三：远程登录密码输错次数的用户管理<br>3.1 查看某一个用户近期输错了几次密码</h4>



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



<h4 id="3-2-重制某一个用户登录密码输错次数">3.2 重制某一个用户登录密码输错次数</h4>



<pre class="wp-block-code"><code># pam_tally2 -u &lt;user&gt; -r --reset</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux su 命令白名单的设置</title>
		<link>https://eternalcenter-may-1-2022.github.io/su-white-list/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 05 Mar 2021 08:24:01 +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 (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<guid isPermaLink="false">https://eternalcenter-may-1-2022.github.io/?p=13611</guid>

					<description><![CDATA[步骤一：设置只能属于某一个组的用户才能使用 su 命令1.1 CentOS&#38;RHEL 设置只能属于某一个组的用户才能使用 su 命令 （补充：这里以设置只能 wheel 才能使用 su 命令为例） 1.2 openSUSE&#38;SUSE 设置只能属于某一个组的用户才能使用 su 命令 （补充：这里以设置只能 wheel 才能使用 su 命令为例） 步骤二：将需要使用 su 命令的用户添加到可以使用 su 命令的组 （补充：这里以给 eternalcenter 用户添加 wheel 附属所属组为例） 步骤三：验证 su 命令白名单3.1 以其他普通用户的身份使用 su 命令切换到其他用户 （步骤略） （补充：就算密码正确也会显示 su: Authentication failure） 3.2 以在白名单用户的身份使用 su 命令切换到其他用户]]></description>
										<content:encoded><![CDATA[
<h4>步骤一：设置只能属于某一个组的用户才能使用 su 命令<br>1.1 CentOS&amp;RHEL 设置只能属于某一个组的用户才能使用 su 命令</h4>



<pre class="wp-block-code"><code># sed -i '/auth.*include.*common-auth/a     auth     required       pam_wheel.so use_uid' /etc/pam.d/su</code></pre>



<p>（补充：这里以设置只能 wheel 才能使用 su 命令为例）</p>



<h4>1.2 openSUSE&amp;SUSE 设置只能属于某一个组的用户才能使用 su 命令</h4>



<pre class="wp-block-code"><code># sed -i '/auth.*include.*common-auth/a     auth     required       pam_wheel.so use_uid' /etc/pam.d/su
# sed -i '/auth.*include.*common-auth/a     auth     required       pam_wheel.so use_uid' /etc/pam.d/su-l</code></pre>



<p>（补充：这里以设置只能 wheel 才能使用 su 命令为例）</p>



<h4>步骤二：将需要使用 su 命令的用户添加到可以使用 su 命令的组</h4>



<pre class="wp-block-code"><code># usermod -a -G wheel eternalcenter</code></pre>



<p>（补充：这里以给 eternalcenter 用户添加 wheel 附属所属组为例）</p>



<h4>步骤三：验证 su 命令白名单<br>3.1 以其他普通用户的身份使用 su 命令切换到其他用户</h4>



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



<p>（补充：就算密码正确也会显示 su: Authentication failure）</p>



<h4>3.2 以在白名单用户的身份使用 su 命令切换到其他用户</h4>



<pre class="wp-block-code"><code># su - eternalcenter
$ su - root</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] GRUB2 Bootloader 密码的设置 （CentOS Linux &#038; RHEL 版）</title>
		<link>https://eternalcenter-may-1-2022.github.io/grub2-bootloader-centos-linux-rhel/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 05 Mar 2021 07:43:06 +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-may-1-2022.github.io/?p=13602</guid>

					<description><![CDATA[步骤一：生成密码的 GRUB2 密码的 SHA512 值 （补充：这里以生成 eternalcenter 的 GRUB2 SHA512 值为例） （注意：grub.pbkdf2.sha512.10000……. 后面的一长串字母和数字其实是一行，这里因为是显示问题所以看上去是多行） 步骤二：创建 GRUB2 密码文件2.1 给 EFI 的 CentOS &#38; RHEL 创建 GRUB2 密码文件 （补充：1) 登录用户 root2) 登陆密码 eternalcenter3) 这里的 grub.pbkdf2.sha512.10000.B857B…… 是由步骤一生成的） （注意：这里其实只有一行，因为是显示问题所以看上去是多行） 2.2 给 BIOS 的 CentOS &#38; RHEL 创建 GRUB2 密码文件 （补充：1) 登录用户 root2) 登陆密码 eternalcenter3) 这里的 grub.pbkdf2.sha512.10000.B857B…… 是由步骤一生成的） （注意：这里其实只有一行，因为是显示问题所以看上去是多行） 步骤三：测试 GRUB2 &#8230; <p class="link-more"><a href="https://eternalcenter-may-1-2022.github.io/grub2-bootloader-centos-linux-rhel/" class="more-link">Continue reading<span class="screen-reader-text"> "[步骤] GRUB2 Bootloader 密码的设置 （CentOS Linux &#038; RHEL 版）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h4>步骤一：生成密码的 GRUB2 密码的 SHA512 值</h4>



<pre class="wp-block-code"><code># grub2-mkpasswd-pbkdf2
Enter password: 
Reenter password: 
PBKDF2 hash of your password is 
grub.pbkdf2.sha512.10000.
B857B79D02FF55CA3A69B8485C1A4A427424630C804CC8A89134520A34E056D7882A778F6BC8AD856CB95DF8B99BE25F9FEAD899D826BB3915FB20BAD682D10A.4A1CF49B7F815A0578031CCA2CE98C66BDFBEAB0AE2721531BB54AFC6CFFA990FBD9062F41C006376C283B717FEC1BD9BB1AFB882AF91B5F4A812459D7974D1F</code></pre>



<p>（补充：这里以生成 eternalcenter 的 GRUB2 SHA512 值为例）</p>



<p>（注意：grub.pbkdf2.sha512.10000……. 后面的一长串字母和数字其实是一行，这里因为是显示问题所以看上去是多行）</p>



<h4>步骤二：创建 GRUB2 密码文件<br>2.1 给 EFI 的 CentOS &amp; RHEL 创建 GRUB2 密码文件</h4>



<pre class="wp-block-code"><code>echo "GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.B857B79D02FF55CA3A69B8485C1A4A427424630C804CC8A89134520A34E056D7882A778F6BC8AD856CB95DF8B99BE25F9FEAD899D826BB3915FB20BAD682D10A.4A1CF49B7F815A0578031CCA2CE98C66BDFBEAB0AE2721531BB54AFC6CFFA990FBD9062F41C006376C283B717FEC1BD9BB1AFB882AF91B5F4A812459D7974D1F" &gt; /boot/efi/EFI/redhat/user.cfg</code></pre>



<p>（<br>补充：<br>1) 登录用户 root<br>2) 登陆密码 eternalcenter<br>3) 这里的 grub.pbkdf2.sha512.10000.B857B…… 是由步骤一生成的<br>）</p>



<p>（注意：这里其实只有一行，因为是显示问题所以看上去是多行）</p>



<h4>2.2 给 BIOS 的 CentOS &amp; RHEL 创建 GRUB2 密码文件</h4>



<pre class="wp-block-code"><code>echo "GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.B857B79D02FF55CA3A69B8485C1A4A427424630C804CC8A89134520A34E056D7882A778F6BC8AD856CB95DF8B99BE25F9FEAD899D826BB3915FB20BAD682D10A.4A1CF49B7F815A0578031CCA2CE98C66BDFBEAB0AE2721531BB54AFC6CFFA990FBD9062F41C006376C283B717FEC1BD9BB1AFB882AF91B5F4A812459D7974D1F" &gt; /boot/grub2/user.cfg</code></pre>



<p>（<br>补充：<br>1) 登录用户 root<br>2) 登陆密码 eternalcenter<br>3) 这里的 grub.pbkdf2.sha512.10000.B857B…… 是由步骤一生成的<br>）</p>



<p>（注意：这里其实只有一行，因为是显示问题所以看上去是多行）</p>



<h4>步骤三：测试 GRUB2 Bootloader 密码<br>3.1 重启系统</h4>



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



<h4>3.2 进入到 GRUB2 Bootloader 模式</h4>



<p>当启动系统时按下 “E” 键</p>



<h4>补充：更改 GRUB2 的登陆用户<br>补充一：给 EFI 的 CentOS &amp; RHEL 更改 GRUB2 的登陆用户</h4>



<pre class="wp-block-code"><code># echo &lt;user&gt; &gt; /boot/efi/EFI/redhat/user.cfg</code></pre>



<h4>补充二：给 BIOS 的 CentOS &amp; RHEL 更改 GRUB2 的登陆用户</h4>



<pre class="wp-block-code"><code># echo &lt;user&gt; &gt; /boot/grub2/user.cfg</code></pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
