<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>SSH on 南山小记</title><link>https://z2n8q.667775.xyz/tags/ssh/</link><description>Recent content in SSH on 南山小记</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Sat, 23 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://z2n8q.667775.xyz/tags/ssh/index.xml" rel="self" type="application/rss+xml"/><item><title>SSH 免密登录配置</title><link>https://z2n8q.667775.xyz/posts/ssh-key-login/</link><pubDate>Sat, 23 May 2026 00:00:00 +0000</pubDate><guid>https://z2n8q.667775.xyz/posts/ssh-key-login/</guid><description>生成密钥、传公钥、写 config，一次配好。</description><content:encoded><![CDATA[<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ssh-keygen -t ed25519 -C <span style="color:#e6db74">&#34;me@example.com&#34;</span>
</span></span><span style="display:flex;"><span>ssh-copy-id -p <span style="color:#ae81ff">2222</span> user@host
</span></span></code></pre></div><h2 id="config-写法">config 写法</h2>
<p><code>~/.ssh/config</code>：</p>
<pre tabindex="0"><code>Host myserver
    HostName 203.0.113.10
    Port 2222
    User deploy
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 30
</code></pre><p>之后 <code>ssh myserver</code> 就够了。</p>
<h2 id="权限">权限</h2>
<p><code>.ssh</code> 目录 700，<code>authorized_keys</code> 600，<code>config</code> 600。权限不对 sshd 会直接拒绝。</p>
<h2 id="关闭密码登录">关闭密码登录</h2>
<pre tabindex="0"><code>PasswordAuthentication no
PermitRootLogin prohibit-password
</code></pre><p>改完 <code>sshd -t</code> 检查语法，再 reload。别把自己锁在门外——先开一个新终端验证能登录再关旧的。</p>
]]></content:encoded></item></channel></rss>