新手问题 [已解决] Capistrano 用户验证问题?

chairy11 · 2014年11月19日 · 最后由 torvaldsdb 回复于 2017年10月31日 · 8753 次阅读

问题

在我的理解里,我在自己的 app 代码中部署好了 capistrano , 输入

cap production deploy:setup

然后它提示我输入密码,应该就搞定了……

可事实是,它没让我输入密码,直接就提示我

DEBUG[dd17face] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx
DEBUG[dd17face] Command: [ -d ~/.rvm ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on hostxxx.xxxx.xxxx.xx
: Authentication failed for user [email protected]


Net::SSH::AuthenticationFailed: Authentication failed for user [email protected]

Tasks: TOP => rvm:hook

怎么破?

后来,我就在 config/environments/production.rb 中加了一句

set :password, ask('Server password:', nil)
server 'server.domain.com', user: 'ssh_user_name', port: 22, password: fetch(:password), roles: %w{web app db}

它倒是问我密码了,可是竟然明文显示密码,这就算了,结果还是搞不定,显示的结果是:

$ cap production deploy:setup        

Please enter Server password (): xxxx
DEBUG[5db14c73] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx

DEBUG[ab50c1ba] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx

DEBUG[ab50c1ba] Command: [ -d ~/.rvm ]
DEBUG[5db14c73] Command: [ -d ~/.rvm ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxxx.xxxx.xx
: connection closed by remote host

Net::SSH::Disconnect: connection closed by remote host

EOFError: end of file reached

Tasks: TOP => rvm:hook
(See full trace by running task with --trace)

难道会是我的 rvm 地址没设置对吗?

好吧,目前我正在研究这个文档

解决方案

增加从本机到服务器的 SSH

# Mac OSX 上 ssh-copy-id不是默认安装的,可通过Homebrew进行安装
    brew install ssh-copy-id

#  将私钥加入ssh-agent管理:
     ssh-add ira                                       # (注:ira指的是私钥名称)

# 公钥加到远程服务器
      ssh-copy-id -i ~/.ssh/yby.pub [email protected]

建议先学习配置 ssh 连接自己服务器,github,bitbucket. 再回头就简单多了。

在服务器中加入本机的 key

来自 RubyChina4Android

#2 楼 @flowerwrong 我平时 push 代码到 github,bitbucket 都是用 SSH 的。服务器之前 pull 代码也是用 SSH 通过验证的。不过我没试过从自己机子到服务器用 SSH,我折腾下……

#3 楼 @bestjane #2 楼 @flowerwrong 已经在服务器加上我本机的 SSH KEY,因为我现在输入 ssh [email protected],不用密码就能直接进入服务器了。 可是,运行

cap production deploy:check

会出现

DEBUG[9b8c96d0] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxx.xxx.xxx
DEBUG[9b8c96d0] Command: [ -d ~/.rvm ]
DEBUG[9b8c96d0] Finished in 25.961 seconds with exit status 1 (failed).
DEBUG[2447555d] Running /usr/bin/env [ -d /usr/local/rvm ] on xxx.xxx.xxx.xxx
DEBUG[2447555d] Command: [ -d /usr/local/rvm ]
DEBUG[2447555d] Finished in 6.133 seconds with exit status 0 (successful).
DEBUG[7985b73b] Running /usr/local/rvm/bin/rvm version on xxx.xxx.xxx.xxx
DEBUG[7985b73b] Command: /usr/local/rvm/bin/rvm version
DEBUG[7985b73b]     rvm 1.25.34 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG[7985b73b] Finished in 7.365 seconds with exit status 0 (successful).
rvm 1.25.34 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG[dcd2a0bb] Running /usr/local/rvm/bin/rvm current on xxx.xxx.xxx.xxx
DEBUG[dcd2a0bb] Command: /usr/local/rvm/bin/rvm current
DEBUG[dcd2a0bb]     ruby-2.1.2
DEBUG[dcd2a0bb] Finished in 7.068 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG[b8c3e406] Running /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version on xxx.xxx.xxx.xxx
DEBUG[b8c3e406] Command: /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written

SSHKit::Command::Failed: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written

Tasks: TOP => rvm:check

没看懂这是哪里出错了……

昨天听你说你的 gemfile.lock 里面 cap 是 2,你把他删掉,重新重新 bundle install 试下

rm Gemfile.lock
bundle install

[email protected]:FlowerWrong/capdemo.git

#6 楼 @flowerwrong 我本机的已经是 cap 3 了。服务器的我这两天 commit 的没有更新,那看来我在第一次用 cap 之前,还是得先手动更新下次? 我现在进服务器手动 git pull 最新代码了。

手动git pull最新代码 不用,cap production deploy:check 会创建基础环境,过后cap production deploy 要不先玩这个 demo 吧 [email protected]:FlowerWrong/capdemo.git

# https://github.com/FlowerWrong/capdemo/blob/master/config/deploy.rb
set :deploy_to, '/home/ubuntu/www/capdemo'
# https://github.com/FlowerWrong/capdemo/blob/master/config/deploy/production.rb
role :app, %w{ubuntu@xxx}
role :web, %w{ubuntu@xxx}
role :db, %w{ubuntu@2xxx}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server definition into the
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.
server 'xxx', user: 'ubuntu', roles: %w{web app}, my_property: :my_value

#8 楼 @flowerwrong 不懂怎么玩啊。反正我现在按说服务器里刚已经 git pull , 并 bundle install,已经用了 cap 3 了。我还 touch tmp/restart.txt,如果平时手动更新也就这么个步骤了吧?

但还是同样出错。

$ cap production deploy:check --trace


** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Execute rvm:hook
DEBUG[e614ad80] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxx.xxx.xxx
DEBUG[e614ad80] Command: [ -d ~/.rvm ]
DEBUG[e614ad80] Finished in 5.743 seconds with exit status 1 (failed).
DEBUG[ad2818c3] Running /usr/bin/env [ -d /usr/local/rvm ] on xxx.xxx.xxx.xxx
DEBUG[ad2818c3] Command: [ -d /usr/local/rvm ]
DEBUG[ad2818c3] Finished in 1.495 seconds with exit status 0 (successful).
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG[88e3ae89] Running /usr/local/rvm/bin/rvm version on xxx.xxx.xxx.xxx
DEBUG[88e3ae89] Command: /usr/local/rvm/bin/rvm version
DEBUG[88e3ae89]     rvm 1.25.34 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG[88e3ae89] Finished in 1.899 seconds with exit status 0 (successful).
rvm 1.25.34 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG[ef7d1ca6] Running /usr/local/rvm/bin/rvm current on xxx.xxx.xxx.xxx
DEBUG[ef7d1ca6] Command: /usr/local/rvm/bin/rvm current
DEBUG[ef7d1ca6]     ruby-2.1.2
DEBUG[ef7d1ca6] Finished in 1.519 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG[8e5f9ffa] Running /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version on xxx.xxx.xxx.xxx
DEBUG[8e5f9ffa] Command: /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:11:in `block (3 levels) in <top (required)>'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:11:in `block (3 levels) in <top (required)>'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rvm:check

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rvm' # 看下是不是没有加入rvm
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

是 capfile 吧?加了的

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'


# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

但 deploy.rb 中,

# set :rvm_type, :system                     # Defaults to: :auto
set :rvm_ruby_version, '2.1.2p95'
set :rvm_roles, [:app, :web, :db]

在 deploy/production.rb 中

server 'xxx.xxx.xxx.xxx',
       user: 'root',
       roles: %w{web app},
       ssh_options: {
           user: 'root', # overrides user setting above
           keys: %w(/Users/yebiying/.ssh/yby),
           forward_agent: false,
           auth_methods: %w(publickey password)
          # password: 'please use keys'
        }

主要我还是没看出是哪里有错,

SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2

好像都 google 不到 status:2 是指什么……

#10 楼 @flowerwrong 请教一下,deploy/production.rb 中

server 'xxx.xxx.xxx.xxx',
       user: 'root',
       roles: %w{web app},
       ssh_options: {
           user: 'root', # overrides user setting above
           keys: %w(/Users/yebiying/.ssh/yby),
           forward_agent: false,
           auth_methods: %w(publickey password)
          # password: 'please use keys'
        }

那个 keys , 是写的本机的私钥的地址,还是服务器中 publickey 的地址?

#12 楼 @chairy11 部署到一台服务器一般不用写 server 那部分 server 'xxx', user: 'root', roles: %w{web app}, my_property: :my_value 就可以了

地址是你本机的私钥地址

# 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'
#   }

~/.ssh/config

Host bitbucket.org
  User flowerwrong
    Hostname bitbucket.org
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_bitbucket

Host github.com
  User flowerwrong
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github

Host ip
  IdentityFile ~/.ssh/id_rsa_xx

#13 楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在 share 难道不应该是 capinstrano 自己搞的吗?我要自己复制过去?

#13 楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在 share 难道不应该是 capinstrano 自己搞的吗?我要自己复制过去?

#13 楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在 share 难道不应该是 capinstrano 自己搞的吗?我要自己复制过去?

#13 楼 @flowerwrong
另外,my_property: :my_value,这句是干什么的? 我不知道从哪抄了句:

server 'xxx.xxx.xxx.xxx', user: 'root', roles: %w{web app db}, primary: true

但我也不知道 primary: true 是干什么的……

看看 cap 执行的什么命令,自己 ssh 上服务器一条条的敲,看看对不对

#13 楼 @flowerwrong #18 楼 @jimrokliu 现在执行的命令应该是

cap production deploy:check:linked_files

提示的是:

file /var/www/weekly.com/shared/config/database.yml does not exist

我手动复制过去好吗?还是说应该在哪里设置一下的?

#13 楼 @flowerwrong #18 楼 @jimrokliu 额,我手动把 database.yml 复制到 shared 下了…… 是复制不是移动,因为 rails 本身好像是会回到原来的 config 位置找的,另外设置貌似也有点复制,我就先让它同时存在了,这样好吗?

#21 楼 @chairy11 谢谢您的文档,我今天也遇到了。

flowerwrong 回复

建议先学习配置ssh连接自己服务器,github,bitbucket. 再回头就简单多了三年前... 还没接触太多服务器.😅

需要 登录 后方可回复, 如果你还没有账号请 注册新账号