【问题标题】:Capistrano cannot deploy code, because Net::SSH::AuthenticationFailed: Authentication failedCapistrano 无法部署代码,因为 Net::SSH::AuthenticationFailed: Authentication failed
【发布时间】:2014-03-15 16:24:00
【问题描述】:

我们有一个在 Amazon AWS 上运行的 Rails 应用程序。我们连续几个月几乎每天都在推送新代码。

今天,当我尝试在那里部署新代码时,收到以下错误消息:

  * 2014-02-16 13:09:51 executing `deploy'
  * 2014-02-16 13:09:51 executing `deploy:update'
 ** transaction: start
  * 2014-02-16 13:09:51 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@bitbucket.org:my_bitbucket_name/project_name.git master"
    command finished in 2909ms
  * executing "if [ -d /home/deployer/project_name/shared/cached-copy ]; then cd /home/deployer/project_name/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 16958dfcee27dd9c33855ecece0013428e2c57c8 && git clean -q -d -x -f; else git clone -q -b master git@bitbucket.org:rdudacz/looky.co.git /home/deployer/looky/shared/cached-copy && cd /home/deployer/project_name/shared/cached-copy && git checkout -q -b deploy 16958dfcee27dd9c33855ecece0013428e2c57c8; fi"
    servers: ["IP"]
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/project_name/releases/20140216120957; true"
    servers: ["IP"]
 ** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: IP (Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP)
connection failed for: IP (Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP)

这里发生了什么?从哪里开始寻找问题?

【问题讨论】:

    标签: ruby-on-rails ruby amazon-web-services ssh capistrano


    【解决方案1】:

    问题是宝石

    net-ssh

    上一个版本 (2.8.0) 会导致此问题。解决办法是卸载它:

    gem uninstall net-ssh -v 2.8.0
    

    然后将其先前版本添加到 Gemfile:

    gem "net-ssh", "~> 2.7.0"
    

    就是这样。

    【讨论】:

    • 我是Using net-ssh 2.7.0 并且无密码登录工作正常,但仍然得到Net::SSH::AuthenticationFailed
    • 谢谢!似乎 2.9 也存在无法通过端口 22 连接到服务器的问题,而使用 ssh 可以正常工作。恢复到 2.7 工作!
    • 我正在使用 ruby​​-2.1.2p95,安装 net-ssh 2.7.0 后,出现此错误:**/ruby-2.1.2/lib/ruby/2.1.0/rubygems /dependency.rb:298:in `to_specs': 找不到 'net-ssh' (>= 2.8.0) - 确实找到了:[net-ssh-2.7.0] (Gem::LoadError)
    • 我使用的是 net-ssh 2.7.0 遇到了同样的问题
    【解决方案2】:

    我在使用 capistrano 部署时遇到了同样的问题 Net::SSH::AuthenticationFailed: 用户 deployer@IP 身份验证失败

    ssh-copy-id deployer@ip 
    

    这会将您的密钥添加到服务器,您无需密码即可登录。

    【讨论】:

      【解决方案3】:

      卸载 net-ssh 2.8.0 后,也删除 gemfile.lock。会一直没问题的。

      【讨论】:

        【解决方案4】:

        请删除旧的 net-ssh 并按如下方式安装更新,将其添加到您的 gem 文件中,或者可以将其安装在指定 2.9.2 版本的环境中。

        gem 'net-ssh', '~> 2.9.2'
        

        它对我有用。

        【讨论】:

          【解决方案5】:

          对于 deploy.rb 中的 capistrano2

          • net-ssh 2.9.1 设​​置:ssh_options, { config: false}
          • net-ssh 2.9.2 设置:ssh_options, { config: false, number_of_password_prompts: 0 }

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2016-07-13
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2022-06-11
            • 1970-01-01
            • 2016-08-29
            • 2014-02-28
            相关资源
            最近更新 更多