SSHKit::Runner::ExecuteError

可紊 提交于 2019-12-29 03:37:26

问题


$ 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 unexpectedly

SSHKit::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

*

deploy.rb

set :application, 'Psara'
set :repo_url, 'git@bitbucket.org:CBLaughter/psara.git'
set :deploy_to, '/home/Psara/Psara'
set :default_run_options, :pty => true

namespace :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" }

*

production.rb

set :stage, :staging
set :rails_env, :production

role :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, }



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.

*

SSH agent forwarding report


  1. [success] repo_url setting ok

  2. [success] ssh private key file exists

  3. [success] ssh-agent process seems to be running locally

  4. [success] ssh-agent process recognized by ssh-add command

  5. [success] ssh private keys added to ssh-agent

  6. [success] application repository accessible from local machine

  7. [success] all hosts using passwordless login

  8. [success] forward_agent ok for all hosts

  9. [success] ssh agent successfully forwarded to remote hosts

  10. [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.


回答1:


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:

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

More info about ssh-forwarding you can find here.

Other thing you should check manually is that you can ssh to your server (your public key should be added to ~/.ssh/authorized_keys on server), and of course that you can clone your repo locally (that probably you're able to do).

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.




回答2:


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.

Disclaimer, I'm the author of capistrano-ssh-doctor plugin.



来源:https://stackoverflow.com/questions/28375506/sshkitrunnerexecuteerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!