2015-10-20 24 views
2

当我尝试使用本地计算机(MAC){Rails应用}中的capistrano gem部署到服务器时,我得到以下内容。我是新来的轨使用capistrano进行分段的Rails部署会生成以下错误

user-mbp:xp user$ cap staging deploy 
Server password: 
******** 
DEBUG [c6110f69] Running /usr/bin/env [ -d ~/.rbenv ] as [email protected] 
DEBUG [c6110f69] Command: [ -d ~/.rbenv ] 
DEBUG [c6110f69] Finished in 6.956 seconds with exit status 0 (successful). 
INFO [e385c416] Running /usr/bin/env mkdir -p /tmp/pepe/ as [email protected] 
DEBUG [e385c416] Command: (RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p353 /usr/bin/env mkdir -p /tmp/pepe/) 
INFO [e385c416] Finished in 0.098 seconds with exit status 0 (successful). 
DEBUG Uploading /tmp/pepe/git-ssh.sh 0.0% 
INFO Uploading /tmp/pepe/git-ssh.sh 100.0% 
INFO [191046c4] Running /usr/bin/env chmod +x /tmp/pepe/git-ssh.sh as [email protected] 
DEBUG [191046c4] Command: (RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p353 /usr/bin/env chmod +x /tmp/pepe/git-ssh.sh)`enter code here` 
INFO [191046c4] Finished in 0.119 seconds with exit status 0 (successful). 
INFO [bd99c2fc] Running /usr/bin/env git ls-remote --heads ssh://[email protected]/xp.git as [email protected] 
DEBUG [bd99c2fc] Command: (RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p353 GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/pepe/git-ssh.sh /usr/bin/env git ls-remote --heads ssh://[email protected]/xp.git) 
DEBUG [bd99c2fc] Permission denied (publickey,password). 
DEBUG [bd99c2fc] fatal: The remote end hung up unexpectedly 
(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,password). 
fatal: The remote end hung up unexpectedly 

SSHKit::Command::Failed: git exit status: 128 
git stdout: Nothing written 
git stderr: Permission denied (publickey,password). 
fatal: The remote end hung up unexpectedly 

我试过git:check,但仍显示相同。

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,password). 
fatal: The remote end hung up unexpectedly 

Staging.rb

# *************************************************************** # 
require 'highline' 

set :stage, :staging 

set :password, HighLine.new.ask('Server password:') { |q| q.echo = '*'} 
server 'xx.x.com', user: 'deployer', password: fetch(:password), roles: %w{web app db}, primary: true 
set :test_url, 'https://xx.x.com' 
set :version, `git describe --always` 

# you can set custom ssh options 
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options 
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) 
# set it globally 
# set :ssh_options, { 
# keys: %w(/home/rlisowski/.ssh/id_rsa), 
# forward_agent: false, 
# auth_methods: %w(password) 
# } 
# and/or per server 
# server 'example.com', 
# user: 'user_name', 
# roles: %w{web app}, 
# ssh_options: { 
#  user: 'user_name', # overrides user setting above 
#  keys: %w(/home/user_name/.ssh/id_rsa), 
#  forward_agent: false, 
#  auth_methods: %w(publickey password) 
#  # password: 'please use keys' 
# } 
# setting per server overrides global ssh_options 

# fetch(:default_env).merge!(rails_env: :staging) 
+0

我假设你从显影机部署。从你的开发机器,你也推动混帐。这意味着你的开发机器上有你的git证书。您可以在将'set:ssh_options,:forward_agent => true'添加到config/deploy/staging.rb时转发这些内容。如果这不起作用,那么你可以发布你的staging.rb文件。 – sugaryourcoffee

+0

hi @sugaryourcoffee发布了staging.rb文件 –

+0

您是否检查知识库中的公钥是否与您的部署机器上的私钥相匹配?错误表明情况并非如此。如果你在Github上,那么你可以从你的部署机器上检查你是否可以用'ssh -vT git @ github.com'来访问你的仓库。 – sugaryourcoffee

回答

1

有两种可能的解决方案

  1. 私钥复制到部署机器 正如你可以推到Github上(这是我的理解)你的开发机器上有一个私钥和Github上相应的公钥。您可以将您的私钥

    develeopment机$ SCP的〜/ .ssh/id-rsa.pub部署机复制到您的部署机器摆脱错误的:关键

然后ssh来部署的机器,并做

deployment-machine$ mv ~/.ssh/id-rsa.pub ~/.ssh/id-rsa.old 
deployment-machine$ mv ~/key ~/.ssh/id-rsa.pub 
  • 部署的机器上创建密钥,并添加公钥到Github上 有一个易于遵循的解释如何做到这一点的Github Help
  • 希望这有助于。

    链接到项目中使用Capistrano的

    如果你是on Rails的3:

    如果你是on Rails的4:

    +0

    我认为错误的原因是我的本地计算机指向我承诺并推送的特定git,而服务器(生产和分期)都是指向另一个git repo.i使用git remote -v命令检查它。我该如何解决它? –

    +0

    在您的暂存配置文件中将存储库设置为您将代码推送到像'set:repository,'[email protected]:git_user/git_application.git'' – sugaryourcoffee

    +0

    仍然存在相同问题的存储库。我处于危机中stuff.Is有什么办法来解决这个问题,并从我的本地机器部署到登台服务器 –

    相关问题