Ruby-on-rails Capistrano SSH::AuthenticationFailed,不提示输入密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21560297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capistrano SSH::AuthenticationFailed, not prompting for password
提问by Sparkmasterflex
I've been using capistrano successfully for a while now and all of a sudden in every project I've lost the ability to deploy.
我已经成功使用 capistrano 有一段时间了,突然间在每个项目中我都失去了部署的能力。
Environment:
环境:
- os X (Mavericks)
- ruby 1.9.3p194
- rvm (locally, not on server)
- rails 3.2 and up
- RubyGems 1.8.25
- os X(小牛队)
- 红宝石 1.9.3p194
- rvm(本地,不在服务器上)
- 导轨 3.2 及更高版本
- RubyGems 1.8.25
I'm not using rsa_keys or anything I want capistrano to prompt for user and password. Suddenly it has decided not to ask for a password, but does ask for user. Then it rolls back and gives me the following error.
我没有使用 rsa_keys 或任何我想让 capistrano 提示输入用户和密码的东西。突然它决定不要求输入密码,而是要求输入用户。然后它回滚并给我以下错误。
[deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: sub.example.com (Net::SSH::AuthenticationFailed: Authentication failed for user [email protected])
connection failed for: sub.example.com (Net::SSH::AuthenticationFailed: Authentication failed for user [email protected])
This has occurred on my personal laptop and my iMac at work. It occurs when deploying to two different servers (both linux)
这发生在我的个人笔记本电脑和我工作的 iMac 上。它在部署到两个不同的服务器(都是 linux)时发生
I'm completely at a loss here. Any ideas?
我在这里完全不知所措。有任何想法吗?
回答by Sparkmasterflex
Figured it out! Apparently this issue was with net-sshgem. I had version 2.8.0 installed recently with some updates to my development environment and was the cause.
弄清楚了!显然这个问题与net-sshgem 有关。我最近安装了 2.8.0 版,对我的开发环境进行了一些更新,这就是原因。
I'm not sure why it was failing, but gem uninstall net-ssh -v 2.8.0<fixed it for me.
我不确定为什么它失败了,但gem uninstall net-ssh -v 2.8.0<为我修复了它。
If anyone actually knows why this was an issue or how I can correct this issue with the newer version of net-sshI'd be interested to hear it.
如果有人真的知道为什么这是一个问题,或者我如何用较新版本的net-ssh我来纠正这个问题,我会很想听听它。
回答by creativetechnologist
The answer may break your rails app due to gem dependancies.
由于 gem 依赖关系,答案可能会破坏您的 rails 应用程序。
The issue is with net-ssh as was correctly answered by Sparkmasterflex, however whilst this will get capistrano working ok it may break your rails app:
问题出在 net-ssh 上,正如Sparkmasterflex正确回答的那样,但是虽然这将使 capistrano 正常工作,但它可能会破坏您的 rails 应用程序:
These steps fixed both capistrano and rails for me ...
这些步骤为我修复了 capistrano 和 rails ...
- In your Gemfile add
gem 'net-ssh', '2.7.0' - Run
bundle update net-ssh - Run
bundle(just to be sure everything is working ok' - Run
gem uninstall net-ssh -v 2.8.0
- 在你的 Gemfile 添加
gem 'net-ssh', '2.7.0' - 跑
bundle update net-ssh - 运行
bundle(只是为了确保一切正常' - 跑
gem uninstall net-ssh -v 2.8.0
If you are a rails user you should now be able to run both the rails server and capistrano.
如果您是 rails 用户,您现在应该能够同时运行 rails 服务器和 capistrano。
回答by Scott Weldon
I have a workaround that doesn't require downgrading net-ssh, per a comment at the linkthat Zach Liptonposted. Place this code in config/deploy.rb:
net-ssh根据Zach Lipton发布的链接中的评论,我有一个不需要降级的解决方法。将此代码放在:config/deploy.rb
set :ssh_options, {
config: false
#Other options...
}
After I did that, I got another error, Error reading response length from authentication socket.Found the solution to that here. Execute these commands at your Bash prompt:
在我这样做之后,我遇到了另一个错误,Error reading response length from authentication socket.在这里找到了解决方案。在 Bash 提示符下执行这些命令:
$ eval $(ssh-agent)
$ ssh-add
回答by CezarBastos
Upgrading your net-ssh version to 2.8.1 will solve the problem. They released a version bump in 19th february 2014 that fix this and other problems.
将您的 net-ssh 版本升级到 2.8.1 将解决该问题。他们在 2014 年 2 月 19 日发布了一个版本提升,解决了这个问题和其他问题。
- Uninstall your current net-ssh gem (gem install net-ssh -v 'version')
Just paste this on your Gemfile:
gem 'net-ssh', '~> 2.8.1', :git => "https://github.com/net-ssh/net-ssh"
Run bundle install
- 卸载当前的 net-ssh gem (gem install net-ssh -v 'version')
只需将其粘贴到您的 Gemfile 上:
gem 'net-ssh', '~> 2.8.1', :git => " https://github.com/net-ssh/net-ssh"
运行捆绑安装
回答by Anbazhagan p
I had the same problem while deploying using capistrano Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP
使用 capistrano Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP 部署时我遇到了同样的问题
ssh-copy-id deployer@ip
ssh-copy-id deployer@ip
This will add your keys to server and you can login without password.
这会将您的密钥添加到服务器,您无需密码即可登录。
回答by vellotis
set :ssh_options, {
verbose: :debug
}
... helps a lot!
……很有帮助!
I had an issue that I generated my public and private keys with puttygenand exported private key as OpenSSH with name <somename>.id_rsa. An then saved public key with name <somename>.id_rsa.pub.
我遇到了一个问题,我puttygen使用 name生成了我的公钥和私钥,并将私钥导出为 OpenSSH <somename>.id_rsa。然后保存的名为 name 的公钥<somename>.id_rsa.pub。
( ! ) The public key puttygen saves is in RFC 4716 format not PEM. Use publicsuffix instead of pubfor public key file-
( ! ) puttygen 保存的公钥是 RFC 4716 格式而不是 PEM。使用public后缀代替pub公钥文件-
回答by Boomerange
First try to connect to your server with certificate (file.pem) with this command:
首先尝试使用以下命令使用证书 (file.pem) 连接到您的服务器:
ssh -i "file.pem" user@yourServerIp
Then try to run cap production deploy. It solved error for me. I think it is because time limit for certificate expired.
然后尝试运行 cap production deploy。它为我解决了错误。我认为这是因为证书的时间限制已过期。
回答by Muntasim
This snippet works for me:
这个片段对我有用:
group :development do
#.....
gem 'capistrano', "~> 2.15"
gem "net-ssh", "~> 2.7.0"
#.....
end
回答by Jaswinder
If all the above solutions doesn't work,please restart your system as you might be facing the issue due to net-ssh host connections.when you restart and enter the deployment command ,it will ask to add the identity to known hosts.
如果以上所有解决方案都不起作用,请重新启动您的系统,因为您可能面临 net-ssh 主机连接的问题。当您重新启动并输入部署命令时,它会要求将身份添加到已知主机。

