<?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>Permission denied &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/permission-denied/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 15 Feb 2021 02:43:15 +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>[原创] 在Github上添加SSH key</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8github%e4%b8%8a%e6%b7%bb%e5%8a%a0ssh-key/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8github%e4%b8%8a%e6%b7%bb%e5%8a%a0ssh-key/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 06 Oct 2015 05:06:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[Permission denied]]></category>
		<category><![CDATA[ssh key]]></category>
		<category><![CDATA[添加]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=8559</guid>

					<description><![CDATA[<p>
如果你在Github上有一个项目，为了能让这个项目可以在多台计算机上开发，需要把目标计算机的SSH key添加到你的Github账户中，否则你以SSH方式<span style="color:#0000ff;">git clone</span>时会提示无权限，例如你可以试试：</p>
<blockquote>
<p>
		git clone git@github.com:codelast/raspberry-pi.git</p>
</blockquote>
<p>会输出类似于这样的错误信息：</p>
<blockquote>
<p>
		Permission denied (publickey).</p>
</blockquote>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
所以下一步就要在Github中添加SSH key，让你可以在目标计算机上进行开发以及代码提交。<br />
其实Github上已经有完整的教程了，只不过我记性不好，每次都要去翻Github教程，所以特地写下来。</p>
<p><span style="background-color:#00ff00;">✔</span> 检查SSH key是否已经存在<br />
检查文件&#160;~/.ssh/id_rsa.pub 是否存在，如果存在，就不用生成一个新的SSH key了，直接跳到下面的第3步。<br />
如果该文件存在，但你不想使用它的话，那么就按下面的做法另外生成一个文件也可以(例如 ~/.ssh/id_rsa_github.pub)。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);">✔</span>&#160;生成一个新的SSH key<br />
如果第1步中的SSH key不存在，则需要生成：</p>
<blockquote>
<p>
		ssh-keygen -t rsa -b 4096 -C &#34;your_email@example.com&#34;</p>
</blockquote>
<p>其中，your_email@example.com要修改成你的邮箱地址。<br />
回车后输出如下：</p>
<blockquote>
<div>
		Generating public/private rsa key pair.</div></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8github%e4%b8%8a%e6%b7%bb%e5%8a%a0ssh-key/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
如果你在Github上有一个项目，为了能让这个项目可以在多台计算机上开发，需要把目标计算机的SSH key添加到你的Github账户中，否则你以SSH方式<span style="color:#0000ff;">git clone</span>时会提示无权限，例如你可以试试：</p>
<blockquote>
<p>
		git clone git@github.com:codelast/raspberry-pi.git</p>
</blockquote>
<p>会输出类似于这样的错误信息：</p>
<blockquote>
<p>
		Permission denied (publickey).</p>
</blockquote>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
所以下一步就要在Github中添加SSH key，让你可以在目标计算机上进行开发以及代码提交。<br />
其实Github上已经有完整的教程了，只不过我记性不好，每次都要去翻Github教程，所以特地写下来。</p>
<p><span style="background-color:#00ff00;"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span> 检查SSH key是否已经存在<br />
检查文件&nbsp;~/.ssh/id_rsa.pub 是否存在，如果存在，就不用生成一个新的SSH key了，直接跳到下面的第3步。<br />
如果该文件存在，但你不想使用它的话，那么就按下面的做法另外生成一个文件也可以(例如 ~/.ssh/id_rsa_github.pub)。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>&nbsp;生成一个新的SSH key<br />
如果第1步中的SSH key不存在，则需要生成：</p>
<blockquote>
<p>
		ssh-keygen -t rsa -b 4096 -C &quot;your_email@example.com&quot;</p>
</blockquote>
<p>其中，your_email@example.com要修改成你的邮箱地址。<br />
回车后输出如下：</p>
<blockquote>
<div>
		Generating public/private rsa key pair.</div>
<div>
		Enter file in which to save the key (/home/xxx/.ssh/id_rsa):</div>
</blockquote>
<p>其中，xxx是你的用户名，直接回车，会将key保存到默认文件中。<br />
接着会输出：</p>
<blockquote>
<div>
		Enter passphrase (empty for no passphrase):&nbsp;</div>
<div>
		Enter same passphrase again:</div>
</blockquote>
<p>这两步是让你输入一个密码，以及确认密码，这个密码在你提交代码到Github时会用到。将这个密码设置成和另一台可以提交代码的计算机上的那个密码一致（要不然在N台计算机上就有N个密码，太麻烦了）。<br />
回车后就提示成功了：</p>
<blockquote>
<div>
		Your identification has been saved in /home/xxx/.ssh/id_rsa.</div>
<div>
		Your public key has been saved in /home/xxx/.ssh/id_rsa.pub.</div>
<div>
		The key fingerprint is:</div>
<div>
		01:0f:f4:3b:...:f0:a2:db your_email@example.com</div>
</blockquote>
<p>到这一步，你会发现&nbsp;~/.ssh/id_rsa.pub 文件已经生成了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>&nbsp;将SSH key添加到ssh-agent<br />
先确认ssh-agent处于启用状态：</p>
<blockquote>
<p>
		eval &quot;$(ssh-agent -s)&quot;</p>
</blockquote>
<p>输出类似于：</p>
<blockquote>
<p>
		Agent pid 32070</p>
</blockquote>
<p>然后将SSH key添加到ssh-agent：</p>
<blockquote>
<p>
		ssh-add ~/.ssh/id_rsa</p>
</blockquote>
<p>这时又会要你输入密码：</p>
<blockquote>
<p>
		Enter passphrase for /home/xxx/.ssh/id_rsa:</p>
</blockquote>
<p>再次输入前面第2步中设置的密码，回车，这一步就算完成了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>&nbsp;将SSH key添加到Github账户中<br />
将SSH key复制到内存：</p>
<blockquote>
<p>
		xclip -sel clip &lt; ~/.ssh/id_rsa.pub</p>
</blockquote>
<p>如果你的程序没有安装过xclip程序的话，需要先用 sudo apt-get install xclip 安装（对Ubuntu来说）。如果你不想装这个程序，直接 cat&nbsp;~/.ssh/id_rsa.pub 并复制出其中的内容也可以。<br />
然后，在Github个人设置的&ldquo;SSH keys&rdquo;界面中，点击&ldquo;Add SSH key&rdquo;，如下图所示：</p>
<p>在 <span style="color:#0000ff;">Title</span> 栏里填一个有意义的名字，用于标识你这个SSH key是用在哪里的，然后在 Key 那一栏里粘贴上刚用 xclip 命令复制出来的SSH key，最后点击&ldquo;Add key&rdquo;即可将此key添加到你的Github账户中了。</p>
<div style="text-align: center;">
	<img decoding="async" alt="Add an SSH key" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/github_add_ssh_key.png" style="width: 504px; height: 457px;" /></div>
<p>
现在再试试本文一开始所说的git clone命令，你应该可以用SSH方式clone你有权限的项目了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color: rgb(0, 255, 0);"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>&nbsp;设置每次git远程操作时无需输入密码<br />
在进行git远程操作时，例如git pull，git push等命令，会要求你输入密码，为了免密码操作，可以将密码存储：</p>
<blockquote>
<p>
		git config --global credential.helper store</p>
</blockquote>
<p>此外，在 <span style="color:#0000ff;">~/.ssh/config</span>&nbsp;文件中还要做以下配置：</p>
<blockquote>
<div>
		# GitHub</div>
<div>
		Host github.com</div>
<div>
		HostName github.com</div>
<div>
		<span style="background-color:#ff99ff;">AddKeysToAgent yes</span></div>
<div>
		PreferredAuthentications publickey</div>
<div>
		IdentityFile ~/.ssh/id_rsa</div>
</blockquote>
<div>
	这一段配置，会在你git pull的时候自动读取，它的大概含义就是：对github.com域名，指定使用publickey验证，密钥认证使用的私钥文件是&nbsp;IdentityFile ~/.ssh/id_rsa（如果你像前面说的使用了别的文件名例如 id_rsa_github，那么这里也要做相应的修改）。<br />
	<strong><span style="color:#ee82ee;">注意</span></strong>：标红的那一行，我发现在MacOS上没有的话就无效。</div>
<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-%e5%9c%a8github%e4%b8%8a%e6%b7%bb%e5%8a%a0ssh-key/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 树莓派Arch Linux ARM系统更新后无法ssh登录的故障排查</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%bearch-linux-arm%e7%b3%bb%e7%bb%9f%e6%9b%b4%e6%96%b0%e5%90%8e%e6%97%a0%e6%b3%95ssh%e7%99%bb%e5%bd%95%e7%9a%84%e6%95%85%e9%9a%9c%e6%8e%92%e6%9f%a5/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%bearch-linux-arm%e7%b3%bb%e7%bb%9f%e6%9b%b4%e6%96%b0%e5%90%8e%e6%97%a0%e6%b3%95ssh%e7%99%bb%e5%bd%95%e7%9a%84%e6%95%85%e9%9a%9c%e6%8e%92%e6%9f%a5/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 16 Aug 2015 08:38:53 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi/树莓派]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[/etc/shadow]]></category>
		<category><![CDATA[Permission denied]]></category>
		<category><![CDATA[PermitRootLogin]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[root login]]></category>
		<category><![CDATA[system upgrade]]></category>
		<category><![CDATA[树莓派]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=8522</guid>

					<description><![CDATA[<p>
本来用得好好的树莓派（Arch Linux ARM），没啥事随手打了一条系统更新的命令：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
pacman -Syu
</pre>
<p>结果重启之后无法用ssh以root用户登录树莓派了，提示错误如下：</p>
<blockquote>
<p>
		Permission denied, please try again</p>
</blockquote>
<p>这分明就像是密码错误导致的嘛！<br />
<span id="more-8522"></span><br />
一开始，我睁大了眼睛不敢相信，怀疑是密码输错了导致的，但是再三确认之后，情况可以确定了：密码是没错的，但是就是无法登录，试了多个terminal软件都一样，包括Chrome的Secure Shell插件、Ubuntu自带的ssh client，以及PAC。<br />
于是我开始了漫长的问题排查过程。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『1』</span>清除登录用户的登录密码<br />
由于我在树莓派上安装好Arch Linux ARM之后，就一直在家里的内网中使用它，所以也没有特别在意过安全问题，只使用Arch Linux ARM默认的root用户来登录系统（密码是root），因此，我第一个方案想到的就是清除root用户的密码，使得root用户可以无密登录，进了系统以后就一切都好办了。<br />
步骤如下：<br />
把树莓派的TF卡拔下来，接上USB适配器插到一台Ubuntu台式机上，打开<span style="color:#ff0000;">树莓派系统里的</span> <span style="color:#0000ff;">/etc/shadow</span> 文件（该文件保存了用户的登录密码），看到第一行内容类似于：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
root:$6$4kB8D9Mu9$Laa9KKeD/vzCmyyQixAb.Hka...:16450::::::
</pre>
<p>为了安全，当今Linux系统并不是将密码直接保存在 /etc/passwd 文件中（因为该文件是非root用户也可以读取的），而是保存在 <span style="color:#0000ff;">/etc/shadow</span> 文件中，并且密码也不是明文的，而是加密过的&#8212;&#8212;正如大家上面看到的例子一样。<br />
<span style="color:#0000ff;">/etc/shadow</span> 文件的每一行一共有9个字段，每两个字段之间用分号（:）隔开，解释一下几个主要字段的含义：<br />
* 第1个字段：用户名（例如root）<br />
* 第2个字段：用户密码。这个字段最为复杂，里面又以 <span style="color:#ff0000;">$</span> 符号为分隔符，分隔成了几个子字段：<br />
<span style="color:#008000;">6</span>&#160;密码加密方式，6表示密码是使用 SHA-512 算法加密的，这一点从 <span style="color:#0000ff;">/etc/login.defs</span>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%bearch-linux-arm%e7%b3%bb%e7%bb%9f%e6%9b%b4%e6%96%b0%e5%90%8e%e6%97%a0%e6%b3%95ssh%e7%99%bb%e5%bd%95%e7%9a%84%e6%95%85%e9%9a%9c%e6%8e%92%e6%9f%a5/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
本来用得好好的树莓派（Arch Linux ARM），没啥事随手打了一条系统更新的命令：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
pacman -Syu
</pre>
<p>结果重启之后无法用ssh以root用户登录树莓派了，提示错误如下：</p>
<blockquote>
<p>
		Permission denied, please try again</p>
</blockquote>
<p>这分明就像是密码错误导致的嘛！<br />
<span id="more-8522"></span><br />
一开始，我睁大了眼睛不敢相信，怀疑是密码输错了导致的，但是再三确认之后，情况可以确定了：密码是没错的，但是就是无法登录，试了多个terminal软件都一样，包括Chrome的Secure Shell插件、Ubuntu自带的ssh client，以及PAC。<br />
于是我开始了漫长的问题排查过程。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『1』</span>清除登录用户的登录密码<br />
由于我在树莓派上安装好Arch Linux ARM之后，就一直在家里的内网中使用它，所以也没有特别在意过安全问题，只使用Arch Linux ARM默认的root用户来登录系统（密码是root），因此，我第一个方案想到的就是清除root用户的密码，使得root用户可以无密登录，进了系统以后就一切都好办了。<br />
步骤如下：<br />
把树莓派的TF卡拔下来，接上USB适配器插到一台Ubuntu台式机上，打开<span style="color:#ff0000;">树莓派系统里的</span> <span style="color:#0000ff;">/etc/shadow</span> 文件（该文件保存了用户的登录密码），看到第一行内容类似于：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
root:$6$4kB8D9Mu9$Laa9KKeD/vzCmyyQixAb.Hka...:16450::::::
</pre>
<p>为了安全，当今Linux系统并不是将密码直接保存在 /etc/passwd 文件中（因为该文件是非root用户也可以读取的），而是保存在 <span style="color:#0000ff;">/etc/shadow</span> 文件中，并且密码也不是明文的，而是加密过的&mdash;&mdash;正如大家上面看到的例子一样。<br />
<span style="color:#0000ff;">/etc/shadow</span> 文件的每一行一共有9个字段，每两个字段之间用分号（:）隔开，解释一下几个主要字段的含义：<br />
* 第1个字段：用户名（例如root）<br />
* 第2个字段：用户密码。这个字段最为复杂，里面又以 <span style="color:#ff0000;">$</span> 符号为分隔符，分隔成了几个子字段：<br />
<span style="color:#008000;">6</span>&nbsp;密码加密方式，6表示密码是使用 SHA-512 算法加密的，这一点从 <span style="color:#0000ff;">/etc/login.defs</span> 文件中定义的下面这一行也可以证实：</p>
<div>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
ENCRYPT_METHOD  SHA512
</pre>
<p>	还有其他很多加密方式，大家可以用&nbsp;<span style="color:#b22222;">man 3 crypt</span>&nbsp;命令查看一个列表，这里摘抄关键内容如下：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
ID  | Method
────────────────────────────────
1   | MD5
2a  | Blowfish (not in mainline glibc; added in some Linux distributions)
5   | SHA-256 (since glibc 2.7)
6   | SHA-512 (since glibc 2.7)
</pre>
</div>
<p>总之，使用&nbsp;SHA-512 是相对来说最安全的，不要试图改变它。<br />
<span style="color:#008000;">4kB8D9Mu9</span>：一个在生成密码的时候，随机生成的salt字符串，用于增大<a href="https://zh.wikipedia.org/wiki/%E5%BD%A9%E8%99%B9%E8%A1%A8" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">彩虹表</span></a>攻击（破解用户密码）的难度。<br />
<span style="color:#008000;">Laa9KKeD/vzCmyyQixAb.Hka...</span>：加密后的密码。这个字符串很长，所以我这里没有写完，最后用省略号省略了一部分内容。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
从第3个字段起，不是我需要关注的内容，所以这里就不解释了。<br />
要删除root用户的密码，只需要把第1个和第2个冒号之间的那一段内容全部删掉就可以了，变成这样：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
root::16450::::::
</pre>
<p>于是赶紧把TF卡插回树莓派上，启动树莓派，再用root用户登录，依然提示要输密码！直接回车，没用！依然提示&nbsp;Permission denied。<br />
所以这条路是走不通了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#00ff00;">『2』</span>修改root用户的登录密码，而不是删除它<br />
删除root用户的登录密码没用，那我改一个总行了吧？<br />
于是还是找到莓派TF卡上的 <span style="color:#0000ff;">/etc/shadow</span> 文件，这回还是折腾root用户的密码字段，只不过，这一次，我们需要知道如何修改它的密码。<br />
怎样才能生成一个 <span style="color:#0000ff;">/etc/shadow</span> 文件认可的密码字段字符串呢？<br />
答案是使用&nbsp;<span style="color:#ff0000;">mkpasswd</span> 工具。</p>
<div>
	mkpasswd 工具是 whois 这个软件包的一部分，所以要先安装 whois 软件包：</div>
<div>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo apt-get install whois
</pre>
</div>
<div>
	使用命令：</div>
<div>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
mkpasswd -m sha-512
</pre>
</div>
<div>
	然后按提示输入一个明文密码之后，就会生成一个符合 <span style="color: rgb(0, 0, 255);">/etc/shadow</span> 文件要求的密码字段字符串了（$6$...），再把它填到 <span style="color: rgb(0, 0, 255);">/etc/shadow</span> 文件中。</div>
<div>
	把TF卡插回树莓派上，启动树莓派，用root用户登录，依然无效，还提示Permission denied。<br />
	这回我信了，真的不是删密码、改密码可以解决的，一定是有其他什么问题。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
	<span style="background-color:#00ff00;">『3』</span>OpenSSH更新引起的惨案<br />
	我乖乖地跑到Arch的坛子上问了大侠们，很快就有人给出了正确的解答：是<a href="http://lists.mindrot.org/pipermail/openssh-unix-announce/2015-August/000122.html" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">OpenSSH更新</span></a>引起的：默认情况下，不再允许root用户以密码方式ssh登录！</div>
<blockquote>
<div>
		<span style="color:#b22222;">* The default for the sshd_config(5) PermitRootLogin option has changed from &quot;yes&quot; to &quot;prohibit-password&quot;.</span></div>
</blockquote>
<div>
	于是我再次把树莓派的TF卡插到Ubuntu机器上，编辑其上的 <span style="color:#0000ff;">/etc/ssh/sshd_config</span> 文件，把下面这行的注释取消掉：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
#PermitRootLogin yes
</pre>
<p>	然后再启动树莓派，root可以登录了，一切正常！<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
	<span style="background-color:#00ff00;">『4』</span>总结<br />
	其实用root登录是很不好的习惯，我这次就掉坑里了。不说了，我这就建一个新用户去...</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>
</div>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPlain.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%a0%91%e8%8e%93%e6%b4%bearch-linux-arm%e7%b3%bb%e7%bb%9f%e6%9b%b4%e6%96%b0%e5%90%8e%e6%97%a0%e6%b3%95ssh%e7%99%bb%e5%bd%95%e7%9a%84%e6%95%85%e9%9a%9c%e6%8e%92%e6%9f%a5/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
