Ruby-on-rails SSHKit::Runner::ExecuteError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28375506/
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
SSHKit::Runner::ExecuteError
提问by Shion Yamaguchi
$ bundle exec cap production deploy
$ bundle exec cap production deploy
(Backtrace restricted to imported tasks) cap aborted!
SSHKit::Runner::ExecuteError:
Exception while executing as Psara@sakura: git exit status: 128 git stdout: Nothing written git stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedlySSHKit::Command::Failed:
git exit status: 128
git stdout:Nothing written
git stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Tasks: TOP => git:check (See full trace by running task with --trace) The deploy has failed with an error:
Exception while executing as Psara@sakura:
git exit status: 128 git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
(回溯仅限于导入任务)上限中止!
SSHKit::Runner::ExecuteError:
作为 Psara@sakura 执行时出现异常:git 退出状态:128 git stdout:没有写入 git stderr:权限被拒绝(公钥)。
致命:远端意外挂断SSHKit::Command::Failed:
git exit status: 128
git stdout:Nothing write
git stderr: Permission denied (publickey)。
致命:远程端意外挂断
任务:TOP => git:check(通过使用 --trace 运行任务查看完整跟踪)部署失败并出现错误:
以 Psara@sakura
身份执行时出现 异常: git 退出状态:128 git标准输出:没有写
git stderr:权限被拒绝(公钥)。
致命:远端意外挂断
*
*
deploy.rb
set :application, 'Psara'
set :repo_url, '[email protected]:CBLaughter/psara.git'
set :deploy_to, '/home/Psara/Psara'
set :default_run_options, :pty => truenamespace :deploy do
after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: # within release_path do # execute :rake, 'cache:clear' # end end end
end
set :ssh_options, { forward_agent: true, paranoid: true, keys: "~/.ssh/id_rsa" }
部署文件
set :application, 'Psara'
set :repo_url, '[email protected]:CBLaughter/psara.git'
set :deploy_to, '/home/Psara/Psara'
set :default_run_options, :pty => true命名空间:部署做
after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # 在这里我们可以做任何事情,例如: # 在 release_path 内做 # 执行 :rake, 'cache:clear' #结束结束结束
结尾
set :ssh_options, { forward_agent: true, paranoid: true, keys: "~/.ssh/id_rsa" }
*
*
production.rb
set :stage, :staging
set :rails_env, :productionrole :app, %w{sakura}
role :web, %w{sakura}
role :db, %w{sakura}server 'sakura', user: 'Psara', roles: %w{web app}, my_property: >:my_value
set :ssh_options, {
keys: %w(~/.ssh/id_rsa),
forward_agent: false, }
生产.rb
设置:stage, :staging
设置:rails_env, :production角色:app, %w{sakura}
角色:web, %w{sakura}
角色:db, %w{sakura}服务器'sakura',用户:'Psara',角色:%w{web app},my_property:>:my_value
set :ssh_options, {
键: %w(~/.ssh/id_rsa),
forward_agent: false, }
I would be glad, if you could teach me what I can do to solve this problem.
如果你能教我如何解决这个问题,我会很高兴。
I have already added a public key on the bitbucket, but it doesn't work.
我已经在 bitbucket 上添加了一个公钥,但它不起作用。
*
*
SSH agent forwarding report
SSH 代理转发报告
[success]
repo_urlsetting ok[success] ssh private key file exists
[success]
ssh-agentprocess seems to be running locally[success]
ssh-agentprocess recognized byssh-addcommand[success] ssh private keys added to
ssh-agent[success] application repository accessible from local machine
[success] all hosts using passwordless login
[success]
forward_agentok for all hosts[success] ssh agent successfully forwarded to remote hosts
[success] application repository accessible from remote hosts
It seems SSH agent forwarding is set up correctly! You can continue with the deployment process.
It succeeded in all tests, but still makes same error.
[成功]
repo_url设置ok[成功] ssh 私钥文件存在
[成功]
ssh-agent进程似乎在本地运行[成功]
ssh-agent进程被ssh-add命令识别[成功] ssh 私钥添加到
ssh-agent[成功] 可从本地计算机访问的应用程序存储库
[成功] 所有主机使用无密码登录
[成功]
forward_agent适用于所有主机[成功] ssh 代理成功转发到远程主机
[成功] 可从远程主机访问的应用程序存储库
看来 SSH 代理转发设置正确!您可以继续部署过程。
它在所有测试中都成功了,但仍然出现相同的错误。
回答by rastasheep
Make sure that you have ssh-agent running on your machine, because you're using ssh forwarding, your local keys should be able to access and clone your repo from bitbucket. You can run agent it with:
确保您的机器上运行了 ssh-agent,因为您使用的是 ssh 转发,您的本地密钥应该能够从 bitbucket 访问和克隆您的存储库。您可以使用以下命令运行代理:
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
More info about ssh-forwarding you can find here.
您可以在此处找到有关 ssh 转发的更多信息。
Other thing you should check manually is that you can ssh to your server (your public key should be added to ~/.ssh/authorized_keyson server), and of course that you can clone your repo locally (that probably you're able to do).
您应该手动检查的另一件事是您可以通过 ssh 连接到您的服务器(您的公钥应该添加到~/.ssh/authorized_keys服务器上),当然您可以在本地克隆您的存储库(这可能是您可以做到的)。
Update:
更新:
Now i have realised that you turn forwarding for production, in that case you should make sure that key-pair that's on your server (you must have it, because forwarding is turned off), are able to clone repo from bitbucket, you can try cloning on server by hand too.
现在我意识到您将转发用于生产,在这种情况下,您应该确保服务器上的密钥对(您必须拥有它,因为转发已关闭)能够从 bitbucket 克隆 repo,您可以尝试手动克隆到服务器上。
回答by Shion Yamaguchi
As the backtrace says, this is likely related to ssh public keys. I would recommend troubleshooting the problem with capistrano-ssh-doctor. You will get a report precisely saying what went wrong in the setup.
正如回溯所说,这可能与 ssh 公钥有关。我建议使用capistrano-ssh-doctor解决问题。您将收到一份报告,准确说明设置中出了什么问题。
Disclaimer, I'm the author of capistrano-ssh-doctorplugin.
免责声明,我是capistrano-ssh-doctor插件的作者。

