2015-02-06 109 views
16

$ bundle exec cap production deploySSHKit ::亚军:: ExecuteError

(Backtrace restricted to imported tasks) cap aborted!
SSHKit::Runner::ExecuteError:
Exception while executing as [email protected]: 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 [email protected]:
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, '[email protected]: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, }



如果你能教我如何解决这个问题,我会很高兴。

我已经在bitbucket上添加了一个公钥,但它不起作用。

*

SSH代理转发报告


  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.

+0

请编辑您的问题以使用代码块,以便我们可以阅读它。还要清楚地说明你的错误是什么。 – 2015-02-07 00:07:48

+0

@Shion Yamaguchi:你如何解决你的问题,因为我也卡住了!和你在同一页上? – VKatz 2016-03-30 08:17:57

回答

5

由于回溯说,这可能与SSH公共密钥。我会建议通过capistrano-ssh-doctor对问题进行故障排除。你会得到一份报告,准确地说出设置中出了什么问题。

免责声明,我是capistrano-ssh-doctor插件的作者。

+2

对我不起作用:( – VKatz 2016-03-30 10:34:09

39

确保您的计算机上运行着ssh-agent,因为您使用的是ssh forwarding,您的本地密钥应该能够访问并克隆来自bitbucket的repo。你可以运行它与代理:约

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

更多信息SSH转发您可以find here

你应该手动检查的其他事情是你可以ssh到你的服务器(你的公钥应该被添加到服务器上的~/.ssh/authorized_keys),当然你可以在本地克隆你的repo(你可以做的)。

更新:

我现在已经意识到,你转转发生产,在这种情况下,你应该确保密钥对那是你的服务器上(你必须拥有它,因为转发被关闭),是能够从bitbucket克隆repo,您​​也可以手动尝试在服务器上克隆。

+0

嘿Rastasheep即使我面临同样的问题..我经历了但没有能够理清。 – VKatz 2016-03-30 07:53:08

+0

@rastasheep我在这里有一个类似的问题:http://stackoverflow.com/questions/ 36900222/ssh-agent-forwarding-with-capistrano-3-not-working-when-deploy-rails-app。是否Capistrano登录到生产服务器,然后尝试从代码库中将代码提取到生产服务器?如果这就是它确实有办法将Capistrano推送代码从存储库传送到生产服务器吗? – massaskillz 2016-04-27 21:34:27

+0

@massaskillz是的,Capistrano只是通过SSH登录到您的计算机,并且执行由其生成的命令,您可以创建自定义的Capistrano任务做任何你想做的事情。不幸的是,我认为从存储库中“推”不可能,可以从主机复制(通过scp命令)代码到你的服务器。 – rastasheep 2016-04-28 17:18:55