【问题标题】:SSH vagrant Git Permission denied (publickey)SSH vagrant Git 权限被拒绝(公钥)
【发布时间】:2021-01-10 21:36:29
【问题描述】:

我正在使用 MacO、Virtualbox 和 vagrant。在使用vagrant ssh SSH 连接到我的VM 后,我试图运行git fetch。我不断收到错误

权限被拒绝(公钥)。

我在本地机器上生成了 ssh 密钥。并相应地将公钥添加到我的 bitbucket 中。所以,我怀疑我的 ssh 密钥有问题,我查看了很多在线解决方案并尝试了很多,但仍然无法解决问题。

但是,我注意到我在 vm 中没有 ~/.ssh/config 文件。这可能是原因吗?我对 SSH 很陌生,所以我可能在这里遗漏了一个简单而愚蠢的解决方案。

但是,在我的本地有~/.ssh/config,它包含以下内容:

Host 127.0.0.1
AddKeysToAgent yes
ForwardAgent yes

在我的 vagrantFile 中,我设置了 config.ssh.forward_agent = true

当我运行 vagrant provision 时,我收到以下错误:

The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. 
The output for this command should be in the log above. 
Please read the output to determine what went wrong.

【问题讨论】:

    标签: git ssh vagrant


    【解决方案1】:

    配置文件不是强制性的。如果你的 SSH URL 是git@bitbucket.org:<user>/<repo>,它应该可以工作。

    尝试使用包含 Host * 的配置,以防 127.0.0.1 不是正确的方法。
    请参阅“[使用 SSH 代理转发与 Vagrant][1]”

    您需要将your.domain.com 替换为您的 Vagrant box 的域或 IP 地址。
    您可以使用Host * 通配符,但这是一个非常糟糕的主意,因为它让您通过 SSH 连接的每台服务器都可以访问您的密钥。

    所以 '*' 仅用于测试。 [1]:https://wildlyinaccurate.com/using-ssh-agent-forwarding-with-vagrant/

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 2023-03-22
      • 2011-11-25
      • 1970-01-01
      • 1970-01-01
      • 2019-11-24
      • 2014-11-08
      • 2019-03-11
      • 1970-01-01
      相关资源
      最近更新 更多