首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用capistrano部署到暂存的Rails将生成以下错误

使用capistrano部署到暂存的Rails将生成以下错误
EN

Stack Overflow用户
提问于 2015-10-20 18:43:52
回答 1查看 429关注 0票数 2

当我尝试使用本地机器(MAC) {Rails app}中的capistrano gem部署到服务器时,我得到了以下信息。我对rails很陌生

代码语言:javascript
复制
user-mbp:xp user$ cap staging deploy
Server password:
********
DEBUG [c6110f69] Running /usr/bin/env [ -d ~/.rbenv ] as deployer@server.com
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 deployer@server.com
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 deployer@server.com
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://git@git.xxx.xx.com/xp.git as deployer@server.com
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://git@git.xxx.xx.com/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 deployer@server.com: 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,但仍然显示相同的效果。

代码语言:javascript
复制
Tasks: TOP => git:check
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer@server.com: git exit status: 128
git stdout: Nothing written
git stderr: Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly

Staging.rb

代码语言:javascript
复制
# *************************************************************** #
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-21 17:49:34

有两种可能的解决方案

  1. 将您的私钥复制到您的部署机器上,因为您可以将私钥推送到Github (据我所知),您的开发机器上有一个私钥,Github上有相应的公钥。您可以将私钥复制到部署机器上以消除错误。 开发-机器$ scp ~/..ssh/id-rsa.PUB部署-机器:键

然后将ssh放到您的部署机器上,然后执行

代码语言:javascript
复制
deployment-machine$ mv ~/.ssh/id-rsa.pub ~/.ssh/id-rsa.old
deployment-machine$ mv ~/key ~/.ssh/id-rsa.pub
  1. 在您的部署机器上创建一个密钥,并将公钥添加到Github中,在Github帮助中可以很容易地理解如何这样做

希望这能有所帮助。

链接到使用Capistrano的项目

如果您在Rails 3上:

如果您在Rails 4上:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33244443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档