【问题标题】:Bad configuration option: Identityfile错误的配置选项:Identityfile
【发布时间】:2021-10-30 08:44:47
【问题描述】:

我的 ssh 配置没问题,工作正常,但是最近我的 Github ssh 连接不起作用,而且我无法使用 ssh 连接到我的私人服务器。当我尝试 ssh 时,出现以下错误:

/home/hacku/.ssh/config: line 9: Bad configuration option: Identityfile
/home/hacku/.ssh/config: line 16: Bad configuration option: Identityfile
/home/hacku/.ssh/config: terminating, 2 bad configuration options

这是我的配置文件:

Host github.com

User git

Port 22

Hostname github.com

IdentityFile ~/.ssh/github_ssh
TCPKeepAlive yes

Host linode
    HostName serv_ip_address
    User hackU
    Port 22
    IdentityFile ~/.ssh/private_key

我将完全相同的配置文件和我的私钥复制到另一台机器上,它运行良好(Termux,ssh 版本 => OpenSSH_8.6p1,OpenSSL 1.1.1l 2021 年 8 月 24 日)。

我检查了我的 ssh 包版本,它是 OpenSSH_8.7p1,所以我想可能是更新破坏了它。所以我将它降级为 OpenSSH_8.6p1,OpenSSL 1.1.1l 24 Aug 2021,它也没有工作,另外我尝试使用重新启动 sshd

sudo systemctl restart sshd

但以上都不起作用。

我使用 manjaro gnome 版本作为我的日常驱动程序。

先谢谢了。

【问题讨论】:

  • IdentityFile 长期以来一直是一个配置选项,我认为他们不打算在任何时候删除它。也许那里的行尾或字符不好?
  • 我用不同的编辑器打开它,我看不到任何非法字符...
  • 也许用十六进制编辑器看看有没有隐形字符?
  • 我不知道,但它似乎与字符无关,因为我已经从头开始删除并编写了配置文件,但似乎它一直给我同样的错误
  • 好的,关于红鲱鱼,我之前看到随机字符会导致 SSH 配置出现问题,但这里的情况似乎并非如此。

标签: linux openssh manjaro


【解决方案1】:

理论上一切似乎都很好,但问题是它奇怪地抛出了这个错误。看完后I found this information here

如果您使用 ssh-agent,ssh 将自动尝试使用代理中的密钥,即使您没有在 ssh_config 的 IdentityFile(或 -i)选项中指定它们。这是您可能会收到 Too many authentication failures for user 错误的常见原因。使用 IdentitiesOnly yes 选项将禁用此行为。

所以我完全删除了 IdentityFile 选项。因此我的最终配置文件就是这样,两个连接都可以正常工作。

Host github.com
    User git
    Port 22
    Hostname github.com
    TCPKeepAlive yes

Host linode
    HostName server_ip_address
    User hackU
    Port 22

但是,对我来说问题的原因仍然未知。我很高兴听到,以防有人发现。

【讨论】:

    猜你喜欢
    • 2020-08-01
    • 2016-09-12
    • 1970-01-01
    • 2022-01-28
    • 1970-01-01
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多