【问题标题】:Issue with SSH Keys [closed]SSH密钥问题[关闭]
【发布时间】:2020-10-17 14:50:05
【问题描述】:

我有一些非常相似的东西:SSHD Gives error could not open Authorized Keys, although permissions seem correct 但不完全一样。

当我尝试使用我的用户帐户连接到服务器时,我在 /var/log/secure 中看到以下错误消息 错误消息说:

Could not open authorized keys '/home/<username>/$HOME/.ssh/authorized_keys': No such file or directory

这很有意义,但是当我转到 /etc/ssh/sshd_config 文件夹以查看 sshd 服务应该在哪里查找我的授权密钥文件夹时,它显示 $HOME/.ssh/authorized_keys 所以我不确定为什么 SSH 试图追加我的/home/&lt;username&gt;$HOME/.ssh/authorized_keys。我做了仔细检查并运行了以下 cmd:echo $HOME 只是为了确保 $HOME 没有设置不正确。如果有人有任何想法,将不胜感激。

【问题讨论】:

  • 是什么让您认为 $HOME 在该文件中被理解?它由 sshd 守护进程解析,而不是 shell。看起来也许 %h 是你想要的。

标签: linux ssh centos7 redhat ssh-keys


【解决方案1】:

sshd_config 不是 shell 脚本。 $HOME/.ssh/authorized_keys 被视为文字路径,由于它不以/ 开头,所以它被附加到用户的主目录中。

您应该将$HOME 替换为sshd 解释为用户主目录的标记,或者简单地使用相对路径.ssh/authorized_keys(顺便说一句,这是默认值)。

AuthorizedKeysFile  %h/.ssh/authorized_keys

【讨论】:

    猜你喜欢
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 2018-09-13
    • 1970-01-01
    • 2013-09-03
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    相关资源
    最近更新 更多