<?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>ssh &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Fri, 19 Jan 2024 19:42:17 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] MacOS的ssh命令报错：Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e7%9a%84ssh%e5%91%bd%e4%bb%a4%e6%8a%a5%e9%94%99%ef%bc%9alibrary-not-loaded-usr-local-opt-openssl-lib-libcrypto-1-0-0-dylib/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e7%9a%84ssh%e5%91%bd%e4%bb%a4%e6%8a%a5%e9%94%99%ef%bc%9alibrary-not-loaded-usr-local-opt-openssl-lib-libcrypto-1-0-0-dylib/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 19 Jan 2024 19:42:17 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Library not loaded]]></category>
		<category><![CDATA[MacOS]]></category>
		<category><![CDATA[OpenSSH]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=14021</guid>

					<description><![CDATA[<p>MacOS执行一个连接远程服务器的命令 <span style="color:#b22222;">ssh root@192.168.10.78 &#34;mkdir -p /data&#34;</span> 命令时，报错：</p>
<blockquote>
<div>
		dyld[52840]: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib</div>
<div>
		&#160; Referenced from: &#60;此处内容省略&#62; /usr/local/Cellar/openssh/7.8p1/bin/ssh</div>
<div>
		&#160; Reason: tried: &#39;/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/lib/libcrypto.1.0.0.dylib&#39; (no such file, not in dyld cache), &#39;/usr/local/Cellar/openssl@3/3.2.0_1/lib/libcrypto.1.0.0.dylib&#39;</div></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e7%9a%84ssh%e5%91%bd%e4%bb%a4%e6%8a%a5%e9%94%99%ef%bc%9alibrary-not-loaded-usr-local-opt-openssl-lib-libcrypto-1-0-0-dylib/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>MacOS执行一个连接远程服务器的命令 <span style="color:#b22222;">ssh root@192.168.10.78 &quot;mkdir -p /data&quot;</span> 命令时，报错：</p>
<blockquote>
<div>
		dyld[52840]: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib</div>
<div>
		&nbsp; Referenced from: &lt;此处内容省略&gt; /usr/local/Cellar/openssh/7.8p1/bin/ssh</div>
<div>
		&nbsp; Reason: tried: &#39;/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/lib/libcrypto.1.0.0.dylib&#39; (no such file, not in dyld cache), &#39;/usr/local/Cellar/openssl@3/3.2.0_1/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/openssl@3/3.2.0_1/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/Cellar/openssl@3/3.2.0_1/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/local/lib/libcrypto.1.0.0.dylib&#39; (no such file), &#39;/usr/lib/libcrypto.1.0.0.dylib&#39; (no such file, not in dyld cache)</div>
</blockquote>
<div>
	这个问题可能是因为<span style="color:#0000ff;">OpenSSH</span>版本旧导致的。可以尝试更新<span style="color:#0000ff;">OpenSSH</span>来解决：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">brew&nbsp;update
brew&nbsp;upgrade&nbsp;openssh
</code></pre>
</section>
<p>重试，如果仍然报错，可能要尝试重新安装OpenSSH了：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">brew&nbsp;uninstall&nbsp;--ignore-dependencies&nbsp;openssh
brew&nbsp;install&nbsp;openssh
</code></pre>
</section>
<p>
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：<br />
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="color: rgb(77, 77, 77); font-size: 13px; width: 200px; height: 200px;" /><br />
	以及我的微信视频号：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="" src="https://www.codelast.com/wechat_shipinhao_qr_code.jpg" style="text-align: center; width: 200px; height: 199px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-macos%e7%9a%84ssh%e5%91%bd%e4%bb%a4%e6%8a%a5%e9%94%99%ef%bc%9alibrary-not-loaded-usr-local-opt-openssl-lib-libcrypto-1-0-0-dylib/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] ssh连接Linux服务器时提示&quot;Too many authentication failures&quot;的解决办法</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ssh%e8%bf%9e%e6%8e%a5linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%b6%e6%8f%90%e7%a4%batoo-many-authentication-failures%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ssh%e8%bf%9e%e6%8e%a5linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%b6%e6%8f%90%e7%a4%batoo-many-authentication-failures%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 08 Aug 2021 19:01:27 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Too many authentication failures]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13327</guid>

					<description><![CDATA[<div>
	如果你用&#160;<span style="color:#0000ff;">用户名+密码</span> 的方式第一次ssh连接一台Linux服务器，连不上并且报以下错误：</div>
<blockquote>
<div>
		Received disconnect from xxx.xxx.xxx.xxx port 22:2: Too many authentication failures</div>
<div>
		Disconnected from xxx.xxx.xxx.xxx port 22</div>
</blockquote>
<div>
	如果你确定不是因为你输入了太多次错误密码，那么产生这个问题的一个可能原因是：<br />
	在发起连接的机器（<span style="color:#ff0000;">记为A</span>）的 ~/.ssh&#160;目录下放了太多密钥文件，当你连接一台新的服务器并且没有在 ~/.ssh/config&#160;文件中做过特殊的配置时，默认会挨个尝试所有密钥文件，而这些密钥文件，都不是适配那台新服务器的，所以会连接失败。<br />
	<span id="more-13327"></span><br />
	解决这个问题的办法有两种：<br />
	（1）仍然要使用&#160;用户名+密码&#160;的方式登录目标服务器，加&#8220;<span style="color:#0000ff;">PubkeyAuthentication=no</span>&#8221;参数来指定不使用密钥文件
<blockquote>
<p>
			ssh -o PubkeyAuthentication=no root@192.168.15.16</p>
</blockquote>
<p>
	（2）配置使用密钥文件、无密码登录目标服务器<br />
	*&#160;使用另一台机器先登录上目标服务器，按<a href="https://www.codelast.com/?p=10117" rel="noopener" target="_blank"><span style="background-color:#faebd7;">这篇</span></a>文章的做法，把它配置成可以无密码登录服务器。<br />
	*&#160;在A机器上，编辑 ~/.ssh/config&#160;文件，添加如下配置：</p>
<blockquote>
<div>
			Hostname xxx.xxx.xxx.xxx</div>
<div>
			User your_user_name</div>
<div>
			Port 22</div>
<div>
			IdentitiesOnly=yes</div>
<div>
			IdentityFile ~/.ssh/id_rsa_xxx</div></blockquote></div>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-ssh%e8%bf%9e%e6%8e%a5linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%b6%e6%8f%90%e7%a4%batoo-many-authentication-failures%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<div>
	如果你用&nbsp;<span style="color:#0000ff;">用户名+密码</span> 的方式第一次ssh连接一台Linux服务器，连不上并且报以下错误：</div>
<blockquote>
<div>
		Received disconnect from xxx.xxx.xxx.xxx port 22:2: Too many authentication failures</div>
<div>
		Disconnected from xxx.xxx.xxx.xxx port 22</div>
</blockquote>
<div>
	如果你确定不是因为你输入了太多次错误密码，那么产生这个问题的一个可能原因是：<br />
	在发起连接的机器（<span style="color:#ff0000;">记为A</span>）的 ~/.ssh&nbsp;目录下放了太多密钥文件，当你连接一台新的服务器并且没有在 ~/.ssh/config&nbsp;文件中做过特殊的配置时，默认会挨个尝试所有密钥文件，而这些密钥文件，都不是适配那台新服务器的，所以会连接失败。<br />
	<span id="more-13327"></span><br />
	解决这个问题的办法有两种：<br />
	（1）仍然要使用&nbsp;用户名+密码&nbsp;的方式登录目标服务器，加&ldquo;<span style="color:#0000ff;">PubkeyAuthentication=no</span>&rdquo;参数来指定不使用密钥文件</p>
<blockquote>
<p>
			ssh -o PubkeyAuthentication=no root@192.168.15.16</p>
</blockquote>
<p>
	（2）配置使用密钥文件、无密码登录目标服务器<br />
	*&nbsp;使用另一台机器先登录上目标服务器，按<a href="https://www.codelast.com/?p=10117" rel="noopener" target="_blank"><span style="background-color:#faebd7;">这篇</span></a>文章的做法，把它配置成可以无密码登录服务器。<br />
	*&nbsp;在A机器上，编辑 ~/.ssh/config&nbsp;文件，添加如下配置：</p>
<blockquote>
<div>
			Hostname xxx.xxx.xxx.xxx</div>
<div>
			User your_user_name</div>
<div>
			Port 22</div>
<div>
			IdentitiesOnly=yes</div>
<div>
			IdentityFile ~/.ssh/id_rsa_xxx</div>
</blockquote>
<div>
		其中，xxx.xxx.xxx.xxx&nbsp;是目标服务器的IP地址，your_user_name&nbsp;是登录目标服务器的用户名，id_rsa_xxx&nbsp;是用于无密码登录目标服务器的密钥文件。<br />
		<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
		配置好之后，再连接目标服务器就不再出错了。</p>
<p>		<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
		转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
		感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
			<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</p></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ssh%e8%bf%9e%e6%8e%a5linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%97%b6%e6%8f%90%e7%a4%batoo-many-authentication-failures%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 树莓派的 Ubuntu MATE 系统打开 ssh 服务</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84-ubuntu-mate-%e7%b3%bb%e7%bb%9f%e6%89%93%e5%bc%80-ssh-%e6%9c%8d%e5%8a%a1/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84-ubuntu-mate-%e7%b3%bb%e7%bb%9f%e6%89%93%e5%bc%80-ssh-%e6%9c%8d%e5%8a%a1/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 30 Nov 2019 16:32:07 +0000</pubDate>
				<category><![CDATA[Raspberry Pi/树莓派]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Ubuntu MATE]]></category>
		<category><![CDATA[树莓派]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=11120</guid>

					<description><![CDATA[<p>
要查看更多树莓派相关文章，请点击<a href="https://www.codelast.com/?p=5013" rel="noopener noreferrer" target="_blank"><span style="background-color: rgb(255, 160, 122);">这里</span></a>。</p>
<p>在树莓派上<a href="https://www.codelast.com/?p=11069" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">安装好Ubuntu MATE</span></a> 18.04之后，我需要把外挂的显示屏去掉，从此只在command line下使用树莓派，因此要先打开Ubuntu MATE上的ssh服务。<br />
<span id="more-11120"></span><br />
Ubuntu MATE 18.04已经默认安装好了&#160;<span style="color:#0000ff;">openssh-server</span>，因此不需要用&#160;<span style="color:#b22222;">sudo apt install openssh-server</span>&#160;来装了。</p>
<p>接着就是把ssh服务设置成开机自动运行，以及启动ssh服务：</p>
<blockquote>
<div>
		sudo systemctl enable ssh</div>
<div>
		sudo systemctl start ssh</div>
</blockquote>
<div>
	然而你会发现还是无法远程ssh连接到树莓派上。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	这时你需要配置密钥：</div>
<blockquote>
<div>
		sudo dpkg-reconfigure openssh-server</div>
</blockquote>
<div>
	执行这条命令后你什么也不需要做，等着它结束，就会发现已经可以远程ssh连接到树莓派上了。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u></div>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84-ubuntu-mate-%e7%b3%bb%e7%bb%9f%e6%89%93%e5%bc%80-ssh-%e6%9c%8d%e5%8a%a1/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
要查看更多树莓派相关文章，请点击<a href="https://www.codelast.com/?p=5013" rel="noopener noreferrer" target="_blank"><span style="background-color: rgb(255, 160, 122);">这里</span></a>。</p>
<p>在树莓派上<a href="https://www.codelast.com/?p=11069" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">安装好Ubuntu MATE</span></a> 18.04之后，我需要把外挂的显示屏去掉，从此只在command line下使用树莓派，因此要先打开Ubuntu MATE上的ssh服务。<br />
<span id="more-11120"></span><br />
Ubuntu MATE 18.04已经默认安装好了&nbsp;<span style="color:#0000ff;">openssh-server</span>，因此不需要用&nbsp;<span style="color:#b22222;">sudo apt install openssh-server</span>&nbsp;来装了。</p>
<p>接着就是把ssh服务设置成开机自动运行，以及启动ssh服务：</p>
<blockquote>
<div>
		sudo systemctl enable ssh</div>
<div>
		sudo systemctl start ssh</div>
</blockquote>
<div>
	然而你会发现还是无法远程ssh连接到树莓派上。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	这时你需要配置密钥：</div>
<blockquote>
<div>
		sudo dpkg-reconfigure openssh-server</div>
</blockquote>
<div>
	执行这条命令后你什么也不需要做，等着它结束，就会发现已经可以远程ssh连接到树莓派上了。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84-ubuntu-mate-%e7%b3%bb%e7%bb%9f%e6%89%93%e5%bc%80-ssh-%e6%9c%8d%e5%8a%a1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 防范ssh暴力破解攻击（ssh brute force attack）</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%98%b2%e8%8c%83ssh%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e6%94%bb%e5%87%bb%ef%bc%88ssh-brute-force-attack%ef%bc%89/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%98%b2%e8%8c%83ssh%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e6%94%bb%e5%87%bb%ef%bc%88ssh-brute-force-attack%ef%bc%89/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 19 Sep 2010 09:15:36 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[brute]]></category>
		<category><![CDATA[DenyHosts]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[攻击]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=406</guid>

					<description><![CDATA[<p>
	<span style="font-size: 14px;">暴露在网络上的主机都是有风险的，其中一种风险就是ssh暴力破解攻击（ssh brute force attack）。</span></p>
<p>
	<span style="font-size:14px;">请先看看你的Linux主机的 /var/log/secure 文件的内容，如果你发现里面记录有无数条用各种甚至在你的系统中都不存在的用户名来尝试登录你的系统的日志，那么你就要当心了，这很有可能是别人在用工具不断尝试破解你的登录帐号。</span></p>
<p>
	<span style="font-size:14px;">如果你的密码不够复杂，那么很可能你会遭殃。防范的方法有很多种，这里介绍一种用第三方软件来实现防御的方法。</span></p>
<p>
	<span style="font-size:14px;">据网上的资源介绍，有下面几个防御软件：</span></p>
<p>
<span id="more-406"></span></p>
<p>
	<span style="font-size:14px;">sshfilter <a href="http://www.csc.liv.ac.uk/~greg/sshdfilter/" rel="noopener noreferrer" target="_blank">http://www.csc.liv.ac.uk/~greg/sshdfilter/</a></span></p>
<p>
	<span style="font-size:14px;">Fail2Ban &#160;<a href="http://fail2ban.sourceforge.net/" rel="noopener noreferrer" target="_blank">http://fail2ban.sourceforge.net/</a></span></p>
<p>
	<span style="font-size:14px;">DenyHosts <a href="http://denyhosts.sourceforge.net/" rel="noopener noreferrer" target="_blank">http://denyhosts.sourceforge.net/</a></span></p>
<p>
	&#160;</p>
<p>
	<span style="font-size:14px;">这几个软件我没有全部接触过，仅用了DenyHosts。下面就说一下DenyHosts的安装和使用。</span></p>
<p>
	&#160;</p>
<p>
	&#160;</p>
<p>
	<span style="font-size:14px;">到这里去下载：http://sourceforge.net/projects/denyhosts/files/</span></p>
<p>
	<span style="font-size:14px;">下载.tar.gz的安装包就可以了，安装很方便。</span></p>
<p>
	<span style="font-size:14px;">写本文的时候，其版本为2.6（DenyHosts-2.6.tar.gz）。</span></p>
<p>
	&#160;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（1）解压安装包：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">tar zxf DenyHosts-2.6.tar.gz</span></span></p>
<p>
	&#160;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（2）进入解压出来的目录下，然后再安装：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">cd DenyHosts-2.6/</span></span></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">python setup.py install</span></span></p>
<p>
	<span style="font-size:14px;">（会输出一堆信息，不用理会它）</span></p>
<p>
	&#160;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（3）为了能开机自动启动，在系统中做一个名为&#8220;denyhosts&#8221;的符号链接，然后添加到启动项中：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">ln -s /usr/share/denyhosts/daemon-control-dist /etc/init.d/denyhosts</span></span>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%98%b2%e8%8c%83ssh%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e6%94%bb%e5%87%bb%ef%bc%88ssh-brute-force-attack%ef%bc%89/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	<span style="font-size: 14px;">暴露在网络上的主机都是有风险的，其中一种风险就是ssh暴力破解攻击（ssh brute force attack）。</span></p>
<p>
	<span style="font-size:14px;">请先看看你的Linux主机的 /var/log/secure 文件的内容，如果你发现里面记录有无数条用各种甚至在你的系统中都不存在的用户名来尝试登录你的系统的日志，那么你就要当心了，这很有可能是别人在用工具不断尝试破解你的登录帐号。</span></p>
<p>
	<span style="font-size:14px;">如果你的密码不够复杂，那么很可能你会遭殃。防范的方法有很多种，这里介绍一种用第三方软件来实现防御的方法。</span></p>
<p>
	<span style="font-size:14px;">据网上的资源介绍，有下面几个防御软件：</span></p>
<p>
<span id="more-406"></span></p>
<p>
	<span style="font-size:14px;">sshfilter <a href="http://www.csc.liv.ac.uk/~greg/sshdfilter/" rel="noopener noreferrer" target="_blank">http://www.csc.liv.ac.uk/~greg/sshdfilter/</a></span></p>
<p>
	<span style="font-size:14px;">Fail2Ban &nbsp;<a href="http://fail2ban.sourceforge.net/" rel="noopener noreferrer" target="_blank">http://fail2ban.sourceforge.net/</a></span></p>
<p>
	<span style="font-size:14px;">DenyHosts <a href="http://denyhosts.sourceforge.net/" rel="noopener noreferrer" target="_blank">http://denyhosts.sourceforge.net/</a></span></p>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;">这几个软件我没有全部接触过，仅用了DenyHosts。下面就说一下DenyHosts的安装和使用。</span></p>
<p>
	&nbsp;</p>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;">到这里去下载：http://sourceforge.net/projects/denyhosts/files/</span></p>
<p>
	<span style="font-size:14px;">下载.tar.gz的安装包就可以了，安装很方便。</span></p>
<p>
	<span style="font-size:14px;">写本文的时候，其版本为2.6（DenyHosts-2.6.tar.gz）。</span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（1）解压安装包：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">tar zxf DenyHosts-2.6.tar.gz</span></span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（2）进入解压出来的目录下，然后再安装：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">cd DenyHosts-2.6/</span></span></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">python setup.py install</span></span></p>
<p>
	<span style="font-size:14px;">（会输出一堆信息，不用理会它）</span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（3）为了能开机自动启动，在系统中做一个名为&ldquo;denyhosts&rdquo;的符号链接，然后添加到启动项中：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">ln -s /usr/share/denyhosts/daemon-control-dist /etc/init.d/denyhosts</span></span></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">chkconfig --add denyhosts</span></span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（5）到 /usr/share/denyhosts/ 目录下，将配置文件denyhosts.cfg-dist复制为一个新的配置文件&mdash;&mdash;后面会说为什么要这样做：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">cd /usr/share/denyhosts</span></span></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">cp denyhosts.cfg-dist denyhosts.cfg</span></span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（6）修改配置文件：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">vi denyhosts.cfg</span></span></p>
<p>
	<span style="font-size:14px;">配置文件的内容很长，但是我们没有必要修改所有的参数，很多都只要使用默认就够了，但是有一些是必须要改的，部分说明如下：</span></p>
<p>
	&nbsp;</p>
<blockquote>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># ssh日志文件，对RedHat来说，就是这个文件。对其他系统来说，可能不是该文件，请参考详细的说明</span></span></strong></p>
<p>
		SECURE_LOG = /var/log/secure</p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 描述禁止登录的文件</span></span></strong></p>
<p>
		<span style="font-size:14px;">HOSTS_DENY = /etc/hosts.deny</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 当DenyHosts以--purge参数调用时，比这个参数设置的值久的时间的HOSTS_DENY记录将被删除（该参数留空的话，表示从不会清除任何HOSTS_DENY记录）</span></span></strong></p>
<p>
		<span style="font-size:14px;">PURGE_DENY =&nbsp;</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="font-size:14px;"><span style="color:#008000;"># 发生block的情况时，需要block的服务名</span></span></strong></p>
<p>
		<span style="font-size:14px;">BLOCK_SERVICE &nbsp;= sshd</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 最多允许系统中不存在的用户登录失败多少次</span></span></strong></p>
<p>
		<span style="font-size:14px;">DENY_THRESHOLD_INVALID = 2</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 最多允许有效用户登录失败多少次</span></span></strong></p>
<p>
		<span style="font-size:14px;">DENY_THRESHOLD_VALID = 3</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 最多允许root登录失败多少次</span></span></strong></p>
<p>
		<span style="font-size:14px;">DENY_THRESHOLD_ROOT = 3</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 是否做域名反解析</span></span></strong></p>
<p>
		<span style="font-size:14px;">HOSTNAME_LOOKUP=NO</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 用来接收报警信息的邮箱</span></span></strong></p>
<p>
		<span style="font-size:14px;">ADMIN_EMAIL = xxx@163.com</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># smtp服务器地址，当你需要DenyHosts发邮件给你报警的时候，要设置这个参数</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_HOST = smtp.163.com</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># smtp服务器端口</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_PORT = 25</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 登录邮箱帐户的用户名</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_USERNAME=usr</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 登录邮箱帐户的密码</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_PASSWORD=pas</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 邮件中的发件人信息</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_FROM = DenyHosts &lt;xxx@163.com&gt;</span></p>
<p>
		&nbsp;</p>
<p>
		<strong><span style="color:#008000;"><span style="font-size:14px;"># 报警邮件的标题</span></span></strong></p>
<p>
		<span style="font-size:14px;">SMTP_SUBJECT = DenyHosts Report</span></p>
</blockquote>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;">其他的基本上不用改了。</span></p>
<p>
	<span style="color:#fff;"><span style="font-size:14px;">文章来源：http://www.codelast.com/ </span></span></p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（7）启动服务：</span></span></strong></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">/etc/init.d/denyhosts start</span></span></p>
<p>
	<span style="font-size:14px;">（从输出的信息来看，这种启动方法实际上是调用了如下的命令：</span></p>
<p>
	<span style="font-size:14px;"><span style="color:#00f;">/usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg</span></span></p>
<p>
	<span style="font-size:14px;">可见，它使用的配置文件是/usr/share/denyhosts/denyhosts.cfg ，这也是为什么我们在上面的步骤中要把默认的配置文件复制为一个新的配置文件&ldquo;denyhosts.cfg&rdquo;的原因了。）</span></p>
<p>
	&nbsp;</p>
<p>
	<strong><span style="color:#a52a2a;"><span style="font-size:14px;">（8）测试：</span></span></strong></p>
<p>
	<span style="font-size:14px;">从另一台服务器上，以一个不存在的用户名和密码来ssh登录部署了的DenyHosts服务器，如果你在DenyHosts的配置文件中设置的是错误地尝试一次就被block，那么你就会发现你这台登录的客户端服务器被block了。并且，在部署了DenyHosts的服务器上，查看文件 <span style="color:#f00;">/etc/hosts.deny</span> 的内容，会发现多了一条记录，正是屏蔽了登录者的那一条记录，这就说明生效了。</span></p>
<p>
	&nbsp;</p>
<p>
	<span style="color:#fff;"><span style="font-size:14px;">文章来源：http://www.codelast.com/ </span></span></p>
<p>
	<span style="font-size:14px;">备注：</span></p>
<p>
	<span style="font-size:14px;">如果一台服务器被误block了，可以在部署DenyHosts的服务器上，将文件 <span style="color:#f00;">/etc/hosts.deny</span> 中相应的条目删掉，再重启DenyHosts服务（<span style="color:#00f;">/etc/init.d/denyhosts restart</span>），就可以解除block了。</span></p>
<p>
	&nbsp;</p>
<p>
	&nbsp;</p>
<p>
	<span style="font-size:14px;">最后，防范此类攻击有多种方法，可参考类似于下面的文章：</span></p>
<p>
	<span style="font-size:14px;"><a href="http://coolerfeng.blog.51cto.com/133059/50947">http://coolerfeng.blog.51cto.com/133059/50947</a></span></p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%98%b2%e8%8c%83ssh%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e6%94%bb%e5%87%bb%ef%bc%88ssh-brute-force-attack%ef%bc%89/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
