【问题标题】:Capistrano deploy ** Host key verification failedCapistrano 部署 ** 主机密钥验证失败
【发布时间】:2011-10-22 22:34:03
【问题描述】:

我遵循了其他网站的一些建议,但无济于事。当我尝试 cap deploy:cold 我一直收到“主机密钥验证失败”。

我什么都试过了。我已经从我的计算机 ssh'd 到远程,从已知主机中删除和读取两个密钥,从 github 克隆,从服务器和 github 上的本地设置我的公钥。

我在这里错过了什么?


Capfile: https://gist.github.com/1308243


错误: https://gist.github.com/1308255

【问题讨论】:

  • 你添加 ssh_options[:forward_agent] = true 到 deploy.rb 了吗?
  • 我只能从github上给你点这篇文章,看看你能不能解决它:help.github.com/deploy-with-capistrano
  • 你能附上你的 Capfile 和终端输出的日志吗?
  • 另外,我读到 cap deploy:cold 有点过时了。我使用cap deploy:setup 验证服务器是否设置正确,然后使用cap deploy 进行测试。
  • 附加输出并尝试部署:设置。它起作用了,但是当我只做一个直接的 cap:deploy 时,我得到:gist.github.com/1308273

标签: ruby-on-rails capistrano


【解决方案1】:

添加到您的 deploy.rb:

ssh_options[:forward_agent] = true
default_run_options[:pty] = true

或者登录到您正在部署的服务器(作为您的部署用户)并运行:

ssh git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is **:**:**:.
Are you sure you want to continue connecting (yes/no)? yes

大多数时候我看到这个问题是当 github.com 不在你的~/.ssh/known_hosts 中时

【讨论】:

  • +1 将 github 添加到已知主机列表。这通常是这个问题的根本原因。
  • 同格雷格。我将服务器的公钥添加到 github 但我没有尝试连接到它。 $ ssh git@github.com 很好。
  • 成功了。但除此之外,我需要在我的服务器上生成一个密钥(这是一个新的)并将其添加到 github 帐户及其工作!
【解决方案2】:

而不是使用看起来像这样的 git ssh url git@github.com:definelabs/urbanairship.git

使用如下所示的只读网址 git://github.com/definelabs/urbanairship.git

【讨论】:

  • 似乎不再适用,因为私有存储库没有只读存储库 URL
【解决方案3】:

您曾提到 cap deploy:setup 有效而 cap deploy 失败。所以看起来错误消息与 ssh 连接无关,而与 git checkout 相关。这可能是因为您的 git 远程服务器使用基于密钥的身份验证,并且服务器中缺少所需的密钥。

【讨论】:

    【解决方案4】:

    除了

    ssh_options[:forward_agent] = true
    default_run_options[:pty] = true
    

    我还需要做this,如下:

    def add_domain_to_known_hosts(hostname)
      ip_address = "`dig +short A #{hostname}`"
      run "ssh-keygen -R #{hostname}"
      run "ssh-keygen -R #{ip_address}"
      run "ssh-keygen -R #{hostname},#{ip_address}"
      run "ssh-keyscan -H #{hostname},#{ip_address} >> ~/.ssh/known_hosts"
      run "ssh-keyscan -H #{ip_address} >> ~/.ssh/known_hosts"
      run "ssh-keyscan -H #{hostname} >> ~/.ssh/known_hosts"
    end
    

    不过,应该注意的是,capistrano 不鼓励 PTY: https://github.com/capistrano/capistrano#a-word-about-ptys

    【讨论】:

      【解决方案5】:

      与服务器上的~/YOUR_USER_NAME /.ssh/authorized_keys2 相关的一个文件。我相信它应该包含公钥/私钥(两者之一,我认为是私有的?)

      【讨论】:

      • 服务器上的 authorized_keys 文件应该包含您的 public 密钥的文本,通常是本地计算机上的文件 .ssh/id_rsa.pub
      猜你喜欢
      • 2022-12-20
      • 2015-09-07
      • 2012-09-26
      • 1970-01-01
      • 2021-12-25
      • 2013-02-16
      • 1970-01-01
      • 2020-07-15
      • 2018-10-04
      相关资源
      最近更新 更多