<?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>安全运维 &#8211; 编程技术记录</title>
	<atom:link href="https://blog.z6z8.cn/category/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/%E5%AE%89%E5%85%A8%E8%BF%90%E7%BB%B4/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.z6z8.cn</link>
	<description>世界你好!</description>
	<lastBuildDate>Fri, 12 Apr 2024 01:42:35 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Ubuntu 从源码编译Python3</title>
		<link>https://blog.z6z8.cn/2024/04/12/ubuntu-%e4%bb%8e%e6%ba%90%e7%a0%81%e7%bc%96%e8%af%91python3/</link>
					<comments>https://blog.z6z8.cn/2024/04/12/ubuntu-%e4%bb%8e%e6%ba%90%e7%a0%81%e7%bc%96%e8%af%91python3/#respond</comments>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Fri, 12 Apr 2024 01:33:48 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">https://blog.z6z8.cn/?p=1460</guid>

					<description><![CDATA[各个平台的安装过程请参考 安装依赖 // 更新系统 sudo apt-get update sudo apt- [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="https://realpython.com/installing-python/#how-to-install-on-ubuntu-and-linux-mint" title="各个平台的安装过程请参考">各个平台的安装过程请参考</a></p>
<h1>安装依赖</h1>
<pre><code>// 更新系统
sudo apt-get update
sudo apt-get upgrade

// 安装依赖
 sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
       libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
       libncurses5-dev libncursesw5-dev xz-utils tk-dev</code></pre>
<h1>下载源码</h1>
<pre><code>// 需要自己确定对应版本的下载地址，下面连接是3.8.4版本
wget https://www.python.org/ftp/python/3.8.4/Python-3.8.4.tgz

// 解压缩
tar xvf Python-3.8.4.tgz
// 进入目录
cd Python-3.8.4</code></pre>
<h1>编译构建和安装</h1>
<pre><code>//配置环境
./configure --enable-optimizations --with-ensurepip=install

// -j 8标识 使用8个并行编译。量力而为，并行编译很是消耗资源
make //或者 make -j 8

// 安装到/usr/bin等目录（具体目录和版本有关）
sudo make altinstall</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.z6z8.cn/2024/04/12/ubuntu-%e4%bb%8e%e6%ba%90%e7%a0%81%e7%bc%96%e8%af%91python3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntn 重启后无网络连接</title>
		<link>https://blog.z6z8.cn/2024/04/12/ubuntn-%e9%87%8d%e5%90%af%e5%90%8e%e6%97%a0%e7%bd%91%e7%bb%9c%e8%bf%9e%e6%8e%a5/</link>
					<comments>https://blog.z6z8.cn/2024/04/12/ubuntn-%e9%87%8d%e5%90%af%e5%90%8e%e6%97%a0%e7%bd%91%e7%bb%9c%e8%bf%9e%e6%8e%a5/#respond</comments>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Fri, 12 Apr 2024 01:15:30 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">https://blog.z6z8.cn/?p=1458</guid>

					<description><![CDATA[背景 租了一台服务器，某次重启后就无法连接网络了，多次重启后依然无网络连接，networking/networ [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>背景</h1>
<p>租了一台服务器，某次重启后就无法连接网络了，多次重启后依然无网络连接，networking/network manager/ifdown/ifup都无法解决----因为这台服器根本就没有安装这些命令/模块。<br />
最终通过配置dhcpclient解决，解决过程参考了一篇博文（<a href="https://blog.csdn.net/weixin_52018852/article/details/132331351#:~:text=%E7%AC%AC%E4%B8%80%E4%B8%AAExecStart%E5%91%BD%E4%BB%A4%E7%94%A8%E4%BA%8E%E5%90%AF%E5%8A%A8ens33%E7%BD%91%E5%8D%A1%EF%BC%8C%E7%AC%AC%E4%BA%8C%E4%B8%AAExecStart%E5%91%BD%E4%BB%A4%E7%94%A8%E4%BA%8E%E5%90%AF%E5%8A%A8dhclient%E6%9C%8D%E5%8A%A1%E3%80%82,1.%E6%89%93%E5%BC%80%E7%BB%88%E7%AB%AF%EF%BC%8C%E5%B9%B6%E5%88%87%E6%8D%A2%E5%88%B0root%E7%94%A8%E6%88%B7%E6%88%96%E4%BD%BF%E7%94%A8sudo%E5%91%BD%E4%BB%A4%E4%BB%A5%E7%AE%A1%E7%90%86%E5%91%98%E6%9D%83%E9%99%90%E8%BF%90%E8%A1%8C%E4%BB%A5%E4%B8%8B%E5%91%BD%E4%BB%A4%E3%80%82%20%E5%9C%A8Linux%E7%B3%BB%E7%BB%9F%E4%B8%AD%EF%BC%8C%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8systemd%E6%9D%A5%E5%AE%9E%E7%8E%B0%E5%BC%80%E6%9C%BA%E8%87%AA%E5%8A%A8%E5%BC%80%E5%90%AF%E7%BD%91%E5%8D%A1%E5%B9%B6%E5%90%AF%E5%8A%A8dhclient%E6%9C%8D%E5%8A%A1%E3%80%82" title="原文看这里">原文看这里</a>）</p>
<p>解决办法很简单，就是启动dhcpclient，并设置为开机自动启动。</p>
<h1>确定网络接口名称</h1>
<p>首先要确定连接互联网的接口名，通常是ens3。 可以使用<code>ifcconfig</code>命令获取</p>
<pre><code># 网络接口
ens3: ...............

# 网络接口 lo是本地环回接口
lo: ...................
</code></pre>
<h1>启动dhcpclient</h1>
<pre><code>/sbin/ifconfig ens3 up  # 启动ens3网卡
/sbin/dhclient  ens3 # 分配ip地址</code></pre>
<h1>开机自动连接网络</h1>
<p>创建服务文件</p>
<pre><code>vi /etc/systemd/system/ens3-dhclient.service</code></pre>
<p>文件内容如下</p>
<pre><code>[Unit]
Description=Enable ens33 network interface and start dhclient
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/ifconfig ens3 up
ExecStart=/sbin/dhclient ens3

[Install]
WantedBy=default.target</code></pre>
<p>使服务文件生效</p>
<pre><code>systemctl daemon-reload
systemctl enable ens3-dhclient.service
systemctl start ens3-dhclient.service</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.z6z8.cn/2024/04/12/ubuntn-%e9%87%8d%e5%90%af%e5%90%8e%e6%97%a0%e7%bd%91%e7%bb%9c%e8%bf%9e%e6%8e%a5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>手动计算Git Commit ID（Git Hash）</title>
		<link>https://blog.z6z8.cn/2023/05/04/%e6%89%8b%e5%8a%a8%e8%ae%a1%e7%ae%97git-commit-id%ef%bc%88git-hash%ef%bc%89/</link>
					<comments>https://blog.z6z8.cn/2023/05/04/%e6%89%8b%e5%8a%a8%e8%ae%a1%e7%ae%97git-commit-id%ef%bc%88git-hash%ef%bc%89/#respond</comments>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Thu, 04 May 2023 03:40:28 +0000</pubDate>
				<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">https://blog.z6z8.cn/?p=1429</guid>

					<description><![CDATA[关于 Git Commit ID的计算过程讨论，可参考 How is git commit sha1 form [&#8230;]]]></description>
										<content:encoded><![CDATA[<blockquote>
<p>关于 Git Commit ID的计算过程讨论，可参考 <a href="https://gist.github.com/masak/2415865">How is git commit sha1 formed</a></p>
</blockquote>
<h1>计算过程</h1>
<pre><code class="language-shell"># 获取元数据字符串
info=`git cat-file commit HEAD`

# 计算元数据的字符串长度
infoLen=`echo $info | wc -c`
infoLen=${infoLen// /} 

# 拼接字符串
str=`printf &quot;commit %s\0&quot; $infoLen`
str=$str$info

# 计算SHA1
echo $str | shasum</code></pre>
<h1>其他</h1>
<p>使用<code>git cat-file -p hash</code>命令查看git hash代表的具体内容</p>
<pre><code class="language-shell">git cat-file -p 哈希字符串</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.z6z8.cn/2023/05/04/%e6%89%8b%e5%8a%a8%e8%ae%a1%e7%ae%97git-commit-id%ef%bc%88git-hash%ef%bc%89/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>macOS shell 打印所有环境变量</title>
		<link>https://blog.z6z8.cn/2022/09/02/macos-shell-%e6%89%93%e5%8d%b0%e6%89%80%e6%9c%89%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Fri, 02 Sep 2022 10:29:33 +0000</pubDate>
				<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=1264</guid>

					<description><![CDATA[一个set命令就可以了]]></description>
										<content:encoded><![CDATA[<p>一个<code>set</code>命令就可以了</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Windows 10 使用VirtualBox安装 MacOS Monterey</title>
		<link>https://blog.z6z8.cn/2022/07/18/windows-10-%e4%bd%bf%e7%94%a8virtualbox%e5%ae%89%e8%a3%85-macos-monterey/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Mon, 18 Jul 2022 08:40:01 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=1234</guid>

					<description><![CDATA[注意，本文的部分操作需要使用MacOSX操作系统，以用来将dmg文件转换为iso/cdr格式的光盘镜像 操作环 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><code>注意，本文的部分操作需要使用MacOSX操作系统，以用来将dmg文件转换为iso/cdr格式的光盘镜像</code></p>
<h1>操作环境</h1>
<ul>
<li>Windows 10</li>
<li>macOS 12</li>
</ul>
<h1>下载工具</h1>
<ul>
<li>这里下载 <a href="https://mirrors.dtops.cc/ISO/MacOS/">https://mirrors.dtops.cc/ISO/MacOS/</a>  dmg格式的安装包</li>
<li>这里下载 <a href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a>   VirtualBox platform packages安装包和 和 Oracle VM VirtualBox Extension Pack扩展包</li>
</ul>
<h1>安装VirtualBox</h1>
<p>在Windows 10中安装，过程略。</p>
<h2>安装VirtualBox扩展</h2>
<p>打开VirtualBox，按照以下操作路径安装扩展包</p>
<p><code>管理 -&gt; 全局设定 -&gt; 扩展 -&gt; 右侧的添加新包按钮</code></p>
<h1>创建ISO/CDR光盘镜像</h1>
<p>本文在macOS 12环境中操作。</p>
<h2>将dmg安装镜像复制到应用程序中</h2>
<p>本文使用<code>macOS Monterey 12.4 21F79 Installer for CLOVER 5142 and FirPE.dmg</code>安装镜像，双击打开，找到<code>安装macOS Monterey</code>，然后整体拖拽到应用程序路径(/Applications)</p>
<p>理论上这个步骤不是必须的，但是本文测试中发现不在/Applications路径时，后续操作出现异常。</p>
<h2>创建<code>安装macOS Monterey</code>的可引导镜像</h2>
<p>使用hdiutil命令(可参考<a href="https://zhuanlan.zhihu.com/p/151326765">通过 macOS 安装器制作 macOS 安装镜像（可用虚拟机及黑苹果等）</a>)</p>
<pre><code class="language-shell">//创建空白磁盘镜像  此处开辟了14G多的空白空间。空间大小可以自己调整
// monterey 为镜像名称
hdiutil create -o /tmp/monterey -size 14500m -volname monterey -layout SPUD -fs HFS+J

//将monterey.dmg镜像挂载为monterey卷
hdiutil attach /tmp/monterey.dmg -noverify -mountpoint /Volumes/monterey

//将应用程序（/Applications）内的安装包制作成可引导的安装盘
sudo /Applications/Install\ macOS\ Monterey\ beta.app/Contents/Resources/createinstallmedia --volume /Volumes/monterey --nointeraction

//将安装盘数据刻录为iso/cdr光盘镜像
hdiutil convert /tmp/monterey.dmg -format UDTO -o ~/Desktop/monterey.cdr</code></pre>
<h1>创建macOS虚拟机</h1>
<p>打开VirtualBox ，创建虚拟机</p>
<h2>关键配置（其他默认）：</h2>
<ul>
<li>CPU 4核</li>
<li>RAM 8G</li>
<li>显存 128M</li>
<li>磁盘空间 80G</li>
<li>取消软驱启动</li>
<li>启用EFI</li>
<li>使用USB 3.0控制器</li>
</ul>
<h2>执行VirtualBox Code</h2>
<p>此操作在Windows环境之行，且为必要步骤</p>
<pre><code>cd "C:\Program Files\Oracle\VirtualBox\"

VBoxManage.exe modifyvm "虛擬機名稱" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff

VBoxManage setextradata "虛擬機名稱" VBoxInternal/Devices/efi/0/Config/DmiSystemProduct “MacBookPro15,1”

VBoxManage setextradata "虛擬機名稱" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-551B86E5744E2388"

VBoxManage setextradata "虛擬機名稱" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"

VBoxManage setextradata "虛擬機名稱" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

# 如果是使用 AMD CPU 的電腦，請多加入下面這一行。
VBoxManage modifyvm "虛擬機名稱" --cpu-profile "Intel Core i7-6700K"</code></pre>
<h2>挂在光盘镜像，启动虚拟机</h2>
<p>将制作好的ISO/CDR光盘镜像挂载到虚拟机，并设置为第一启动顺序，然后启动虚拟机。正常情况下，可以看到macOS安装引导页面</p>
<h2>格式化磁盘</h2>
<p>在安装引导页面，选择<code>磁盘工具</code>，抹除上述创建的80G虚拟磁盘数据，格式为<code>Mac OS扩展（日志格式）</code>，方案为<code>GUID分区图</code>，完成后关闭磁盘工具</p>
<h2>安装macOS</h2>
<p>在安装引导页面，选择<code>安装macOS xxxxx</code>，等待之行吧</p>
<p>参考<br />
<a href="https://zhuanlan.zhihu.com/p/435975777">Win10安装最新版（macOS Monterey 12.0.1）黑苹果虚拟机</a></p>
<p><a href="https://adersaytech.com/practical-software/install-macos-on-virtualbox.html">10分鐘學會如何在 VirtualBox 安裝 macOS Monterey！</a></p>
<p><a href="https://zhuanlan.zhihu.com/p/151326765">通过 macOS 安装器制作 macOS 安装镜像（可用虚拟机及黑苹果等）</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>关闭Spotlight</title>
		<link>https://blog.z6z8.cn/2021/10/14/%e5%85%b3%e9%97%adspotlight/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Thu, 14 Oct 2021 03:16:47 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=1111</guid>

					<description><![CDATA[原因无他，导致mac笔记本发热严重，要是一两次也就罢了，每天至少一次CPU 100%，打开活动监视器，都是这个 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>原因无他，导致mac笔记本发热严重，要是一两次也就罢了，每天至少一次CPU 100%，打开活动监视器，都是这个Spotlight造成的。</p>
<p>步骤如下</p>
<h2>关闭System Integrity Protection</h2>
<p>进入恢复模式：重启电脑， 按住 Command 和 R。<br />
输入命令</p>
<pre><code>csrutil disable</code></pre>
<p>因为Spotlist服务受System Integrity Protection保护，不关闭的话有可能无法关闭Spotlist服务，报错如下</p>
<pre><code>Unload failed: 150: Operation not permitted while System Integrity Protection is engaged</code></pre>
<h2>关闭Spotlight服务</h2>
<pre><code>sudo mdutil -a -i off
sudo mdutil -a -d
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist</code></pre>
<p>如果收到报错</p>
<pre><code>Unload failed: 113: Could not find specified service</code></pre>
<p>那就先加载Spotlight服务</p>
<pre><code>sudo mdutil -a -i on
sudo launchctl load -w /System/Library/LaunchAgents/com.apple.Spotlight.plist</code></pre>
<p>然后再执行服务卸载</p>
<h2>打开System Integrity Protection</h2>
<p>进入恢复模式：重启电脑， 按住 Command 和 R。<br />
输入命令</p>
<pre><code>csrutil enable</code></pre>
<p><a href="https://macpaw.com/how-to/disable-enable-system-integrity-protection">https://macpaw.com/how-to/disable-enable-system-integrity-protection</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Error: Your Xcode does not support macOS 11.2.</title>
		<link>https://blog.z6z8.cn/2021/04/08/error-your-xcode-does-not-support-macos-11-2/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Thu, 08 Apr 2021 09:28:37 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=987</guid>

					<description><![CDATA[使用brew安装telnet时，报错Error: Your Xcode does not support ma [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>使用brew安装telnet时，报错<code>Error: Your Xcode does not support macOS 11.2. It is either outdated or was modified. Please update your Xcode or delete it if no updates are available.</code></p>
<pre><code>brew install telnet
Updating Homebrew...
Warning: You are using macOS 11.2.
We do not provide support for this pre-release version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
pre-release version.

==> Downloading https://opensource.apple.com/tarballs/libtelnet/libtelnet-13.tar
Already downloaded: /Users/zxs.zl/Library/Caches/Homebrew/downloads/4fe26613ac3f91bd2fa2ed4e9ca39a043c6fd5960c4e0a3f063c672911900665--libtelnet-13.tar.gz
==> Downloading https://opensource.apple.com/tarballs/remote_cmds/remote_cmds-63
Already downloaded: /Users/zxs.zl/Library/Caches/Homebrew/downloads/557d5b69c452e48e5337f6d80e827514cd2218e1c02dcd42f893bd2cafe7d141--remote_cmds-63.tar.gz
Error: Your Xcode does not support macOS 11.2.
It is either outdated or was modified.
Please update your Xcode or delete it if no updates are available.</code></pre>
<p>将Xcode.app先移动到其他位置，然后在运行<code>brew install telnet</code>，最后把Xcode.app移动回来</p>
<pre><code>sudo mv ./Applications/Xcode.app ~/Desktop
brew install telnet
sudo mv ~/Desktop/Xcode.app  ./Applications</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>macos 配置 git ssh访问方式</title>
		<link>https://blog.z6z8.cn/2020/11/27/macos-%e9%85%8d%e7%bd%ae-git-ssh%e8%ae%bf%e9%97%ae%e6%96%b9%e5%bc%8f/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Fri, 27 Nov 2020 10:02:24 +0000</pubDate>
				<category><![CDATA[安全运维]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=933</guid>

					<description><![CDATA[生成 ssh key $ ssh-keygen -t rsa -C "git服务端留存的邮箱地址" Gener [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>生成 ssh key</h2>
<pre><code class="language-shell">$ ssh-keygen -t rsa -C "git服务端留存的邮箱地址" 

Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa): "这里输入ssh key保存路径，不建议使用默认地址"
Enter passphrase (empty for no passphrase): "这里输入密码，建议输入空（方便后续配置）"
Enter same passphrase again: "再输入一遍密码,建议输入空（方便后续配置）"</code></pre>
<p>应生成两个文件，公钥和私钥，文件名形式为<code>xxx</code>(私钥)，<code>xxx_pub</code>或者<code>xxx.pub</code>(公钥)。记住ssh key生成的文件路径。</p>
<blockquote>
<p>默认情况下，ssh会使用<code>~/.ssh/id_rsa</code>这个私钥，但无法处理访问多个ssh远端的场景。</p>
</blockquote>
<h2>配置本地ssh访问git使用的私钥</h2>
<p>打开 <code>~/.ssh/config</code>文件，如果没有则创建一个文本文件，添加如下内容</p>
<pre><code class="language-shell"># 请保证 Host 和 HostName 的值相同 （macos11 实测不相同时，git ssh 访问失败）

# 远端ssh主机别名
Host bitbucket.cmbc.com.cn
    # 远端ssh主机名（域名或者ip都可以）
    HostName bitbucket.cmbc.com.cn
    # 鉴权文件 ，这填写ssh私钥文件路径
    IdentityFile "ssh 私钥文件路径"
    # 使用公钥算法进行鉴权
    PreferredAuthentications publickey</code></pre>
<p>关于 ssh config 更多细节参考 <a href="https://linux.die.net/man/5/ssh_config">https://linux.die.net/man/5/ssh_config</a></p>
<h2>配置git上的鉴权公钥</h2>
<p>不同的git服务方式不一样，以bitbucket为例：<br />
登录bitbucket，依次点击头像 -&gt; Manage account  -&gt; SSH keys -&gt; Add key ，</p>
<p>将ssh 公钥文件内容复制到在输入框中，然后 保存(点击 &quot;Add key&quot; 按钮)</p>
<blockquote>
<p>ssh 公钥形式通常是ssh-rsa  + base64编码的公钥 + 邮箱地址</p>
</blockquote>
<h2>配置本地已有git仓库的访问协议</h2>
<pre><code class="language-shell"># 查询远程仓库地址
git remote -v

# 添加ssh协议  地址需要访问网页版的bitbucket仓库获取
git remote set-url --add origin ssh://git@bitbucket.cmbc.com.cn:7999/xxx/xxx.git

# 删除http协议 地址由git remote -v获得
git remote set-url --delete origin http://usernamge@bitbucket.cmbc.com.cn:7999/scm/xxx/xxx.git </code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>git patch 文件冲突时的解决办法</title>
		<link>https://blog.z6z8.cn/2020/07/06/git-patch-%e6%96%87%e4%bb%b6%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Mon, 06 Jul 2020 10:29:08 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<category><![CDATA[git]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=875</guid>

					<description><![CDATA[生成patch 1、生成当前分支的patch 生成当前分支指定节点之后的所有patch 生成的patch，会根 [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>生成patch</h2>
<p>1、生成当前分支的patch</p>
<p>生成当前分支指定节点之后的所有patch<br />
生成的patch，会根据节点顺序自动编号，一个commit生成一个patch文件</p>
<pre><code class="language-shell">git format-patch 404777e8586393d5eb6581485fc1bb2bf2e8eb2a //这里长短commit id都可以</code></pre>
<p>2、生成两个节点之间的patch</p>
<pre><code class="language-shell">git format-patch  节点开始..节点结束 //这里长短commit id都可以
//例如
git format-patch aed12..ecf3a</code></pre>
<p>更多详细 <a href="https://blog.csdn.net/sunnylgz/article/details/7661920">https://blog.csdn.net/sunnylgz/article/details/7661920</a></p>
<h2>使用patch</h2>
<p>生成patch相对容易，使用时却有些麻烦，尤其是有冲突的时候。<br />
对于有冲突的patch，用搜索引擎搜索出的结果大都是</p>
<pre><code class="language-shell">git apply --reject patch文件
//对于冲突，会生成.rej文件，然后手动解决所有冲突</code></pre>
<p>这种办法在有冲突时，并不好用（因为根据.rej文件手动解决冲突比较麻烦）<br />
我尝试的一个简单方法是</p>
<pre><code class="language-shell">git am --3way patch文件
//解决冲突后
git am --continue</code></pre>
<p><code>--3way</code>，会尝试合并冲突到目标文件，而不是另生成.rej文件，这样的好处是可以使用成熟的冲突解决工具</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【转】ssh访问控制，多次失败登录即封掉IP，防止暴力破解</title>
		<link>https://blog.z6z8.cn/2020/06/27/%e3%80%90%e8%bd%ac%e3%80%91ssh%e8%ae%bf%e9%97%ae%e6%8e%a7%e5%88%b6%ef%bc%8c%e5%a4%9a%e6%ac%a1%e5%a4%b1%e8%b4%a5%e7%99%bb%e5%bd%95%e5%8d%b3%e5%b0%81%e6%8e%89ip%ef%bc%8c%e9%98%b2%e6%ad%a2%e6%9a%b4/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Sat, 27 Jun 2020 00:29:20 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=872</guid>

					<description><![CDATA[读取/var/log/secure，查找关键字 Failed，例如： Sep 17 09:08:09 loca [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>读取/var/log/secure，查找关键字 Failed，例如：</p>
<p>Sep 17 09:08:09 localhost sshd[29087]: Failed password for root from 13.7.3.6 port 44367 ssh2<br />
Sep 17 09:08:20 localhost sshd[29087]: Failed password for root from 13.7.3.6 port 44367 ssh2<br />
Sep 17 09:10:02 localhost sshd[29223]: Failed password for root from 13.7.3.6 port 56482 ssh2<br />
Sep 17 09:10:14 localhost sshd[29223]: Failed password for root from 13.7.3.6 port 56482 ssh2</p>
<p>从这些行中提取IP地址，如果次数达到10次(脚本中判断次数字符长度是否大于1)则将该IP写到 <code>/etc/hosts.deny</code>中。</p>
<p>步骤：</p>
<p>1、先把始终允许的IP填入 /etc/hosts.allow ，这很重要！比如：<br />
sshd:19.16.18.1:allow<br />
sshd:19.16.18.2:allow</p>
<p>2、脚本 /usr/local/bin/secure_ssh.sh</p>
<pre><code class="language-bash">#! /bin/bash
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' &gt; /usr/local/bin/black.list
for i in &lt;code&gt;cat  /usr/local/bin/black.list&lt;/code&gt;
do
  IP=&lt;code&gt;echo $i |awk -F= &#039;{print $1}&#039;&lt;/code&gt;
  NUM=&lt;code&gt;echo $i|awk -F= &#039;{print $2}&#039;&lt;/code&gt;
  if [ ${#NUM} -gt 1 ]; then
    grep $IP /etc/hosts.deny &gt; /dev/null
    if [ $? -gt 0 ];then
      echo "sshd:$IP:deny" &gt;&gt; /etc/hosts.deny
    fi
  fi
done</code></pre>
<p>3、将secure_ssh.sh脚本放入cron计划任务，每1分钟执行一次。</p>
<h1>crontab -e</h1>
<p><em>/1 </em> <em> </em> *  sh /usr/local/bin/secure_ssh.sh</p>
<p>原文：<a href="https://www.cnblogs.com/panblack/p/secure_ssh_auto_block.html">https://www.cnblogs.com/panblack/p/secure_ssh_auto_block.html</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
