<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘新修]]></title> 
<link>http://pic1.liuxinxiu.com:80/index.php</link> 
<description><![CDATA[刘新修的个人博客 (Liuxinxiu'S Blog)]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘新修]]></copyright>
<item>
<link>http://pic1.liuxinxiu.com:80/s//</link>
<title><![CDATA[SSH密钥登录]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Linux/Unix]]></category>
<pubDate>Sat, 03 Jun 2023 03:30:55 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/s//</guid> 
<description>
<![CDATA[ 
	<p>&nbsp;### 本地机器生成密钥</p><div>ssh-keygen -t rsa</div><div>&nbsp;</div><div>[root@localhost ~]# ssh-keygen -t rsa</div><div>Generating public/private rsa key pair.</div><div>Enter file in which to save the key (/root/.ssh/id_rsa):&nbsp;</div><div>Created directory '/root/.ssh'.</div><div>Enter passphrase (empty for no passphrase):&nbsp;</div><div>Enter same passphrase again:&nbsp;</div><div>Your identification has been saved in /root/.ssh/id_rsa</div><div>Your public key has been saved in /root/.ssh/id_rsa.pub</div><div>The key fingerprint is:</div><div>SHA256:PeMmQH0e2HL+jxZjYJ6/8Hej+ANJ06gm+sUIhzCLNho root@localhost</div><div>The key's randomart image is:</div><div>+---[RSA 3072]----+</div><div>&#124;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#124;</div><div>&#124;&nbsp; &nbsp; &nbsp; &nbsp;. o&nbsp; &nbsp; &nbsp; &nbsp;&#124;</div><div>&#124;&nbsp; &nbsp;o&nbsp; . + = o&nbsp; &nbsp; &#124;</div><div>&#124;&nbsp; . +..&nbsp; Bo= .&nbsp; &nbsp;&#124;</div><div>&#124;E+ . o..SoOoo&nbsp; &nbsp; &#124;</div><div>&#124;o..&nbsp; &nbsp;ooo+o*+&nbsp; &nbsp; &#124;</div><div>&#124;.&nbsp; &nbsp; &nbsp;..+o+ooo&nbsp; &nbsp;&#124;</div><div>&#124;&nbsp; &nbsp; &nbsp;.&nbsp; .o o++...&#124;</div><div>&#124;&nbsp; &nbsp; &nbsp; ..&nbsp; &nbsp;o==+..&#124;</div><div>+----[SHA256]-----+</div><div>[root@localhost ~]#&nbsp;</div><div>&nbsp;</div><div>进入主机A ~/.ssh/ 目录，会发现生成了一对密钥</div><div>Your identification has been saved in /home/test/.ssh/id_rsa.</div><div>Your public key has been saved in /home/test/.ssh/id_rsa.pub.</div><div>&nbsp;</div><div>### A将公钥文件中的内容复制到 ==&gt; 远程服务器端B</div><div>~/.ssh/id_rsa.pub</div><div>~/.ssh/authorized_keys</div><div>&nbsp;</div><div>## 步骤如下</div><div>[root@localhost .ssh]# pwd</div><div>/root/.ssh</div><div>[root@localhost .ssh]# ll</div><div>total 12</div><div>-rw------- 1 root root 891 Jun&nbsp; 1 14:52 id_rsa</div><div>-rw-r--r-- 1 root root 228 Jun&nbsp; 1 14:52 id_rsa.pub</div><div>-rw-r--r-- 1 root root 172 Jun&nbsp; 1 22:28 known_hosts</div><div>[root@localhost .ssh]# vi /root/.ssh/authorized_keys</div><div>&nbsp;</div><div>### 粘贴id_rsa.pub内的字符串到这个文件,对于OpenSSH来说，我们需要将公钥加入到~/.ssh/authorized_keys中。每个公钥一行，千万注意不要换行，否则可能不能正常工作。</div><div>### 修改文件权限</div><div>chmod 600 /root/.ssh/authorized_keys</div><div>&nbsp;</div><div>&nbsp;</div><div>### 修改/etc/ssh/sshd_config 文件</div><div>修改/etc/ssh/sshd_config 文件，将RSAAuthentication 和 PubkeyAuthentication 后面的值都改成yes</div><div>将PasswordAuthentication yes 修改成 PasswordAuthentication no</div><div>&nbsp;</div><div>### 重启SSHD</div><div>/etc/init.d/sshd restart</div>
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/s//#blogcomment</link>
<title><![CDATA[[评论] SSH密钥登录]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/s//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>