ssh:LAN 中登录成功,WAN 中使用 ngrokh 失败

ssh:LAN 中登录成功,WAN 中使用 ngrokh 失败

通过 LAN,我可以使用我的公钥毫无问题地从我的笔记本电脑 ssh 到我的 RPi。

成功情况下 ssh 的调试输出:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: moritz@my_hostname
debug1: Server accepts key: pkalg ssh-rsa blen 279

如果我尝试通过 WAN 使用 ngrok,我会得到以下输出:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: moritz@my_hostname
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/moritz/.ssh/id_rsa
debug1: Trying private key: /home/moritz/.ssh/id_dsa
debug1: Trying private key: /home/moritz/.ssh/id_ecdsa
debug1: Trying private key: /home/moritz/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

在这两种情况下我都这样做ssh pi-user@ip-adress,并且文件在文件/home/pi-user/.ssh/authorized_keys中以正确的形式给出/etc/ssh/sshd_config

在服务器上,我使用 ngrok/ARM 版本,并ngrok 22 使用 Raspberry 连接路由器配置中的服务 ssh 和 https 来启动它。

知道原因吗?

与此同时,我找到了这个答案:

sudo chmod -c g-w /home/lorddaedra 解决了我的问题。因此需要在用户主目录中将 775 更改为 755。如果有人知道 775 不好的原因,请发表评论。

我没有足够的声誉来发表评论,所以这要放在一个单独的答案中。您必须将权限更改为 755 的原因是您将 StrictMode 设置为 yes,这意味着:StrictModes yes 选项 StrictModes 指定 ssh 是否应在接受登录之前检查用户在其主目录和 rhosts 文件中的权限。

来自这篇文章链接至 servefault_SO

我不在家,但下周会尝试一下。

相关内容