新手问题 cap deploy 一直失敗!

jossjoss54 · 2014年10月06日 · 最后由 jossjoss54 回复于 2014年10月15日 · 3329 次阅读

我在用 capistrano 3.2.1 一直遭遇 Authentication failed for user, 看 debug log 就發現停在這了, 如何知道是在哪個階段錯誤了嗎?

D, [2014-10-06T21:13:59.913216 #12980] DEBUG -- net.ssh.authentication.session[3fe6314d7130]: trying none D, [2014-10-06T21:13:59.913372 #12980] DEBUG -- tcpsocket[3fe6325be480]: queueing packet nr 5 type 50 len 44 D, [2014-10-06T21:13:59.913458 #12980] DEBUG -- tcpsocket[3fe6325be480]: sent 68 bytes D, [2014-10-06T21:13:59.991238 #12980] DEBUG -- tcpsocket[3fe6325be480]: read 68 bytes D, [2014-10-06T21:13:59.991620 #12980] DEBUG -- tcpsocket[3fe6325be480]: received packet nr 5 type 51 len 44 D, [2014-10-06T21:13:59.991833 #12980] DEBUG -- net.ssh.authentication.session[3fe6314d7130]: allowed methods: publickey,password D, [2014-10-06T21:13:59.991974 #12980] DEBUG -- net.ssh.authentication.methods.none[3fe6314de7a0]: none failed D, [2014-10-06T21:13:59.992090 #12980] DEBUG -- net.ssh.authentication.session[3fe6314d7130]: trying publickey D, [2014-10-06T21:14:00.016945 #12980] DEBUG -- net.ssh.authentication.agent[3fe6314eb07c]: connecting to ssh-agent D, [2014-10-06T21:14:00.017075 #12980] DEBUG -- net.ssh.authentication.agent[3fe6314eb07c]: sending agent request 1 len 51 D, [2014-10-06T21:14:00.017154 #12980] DEBUG -- net.ssh.authentication.agent[3fe6314eb07c]: received agent packet 2 len 5 D, [2014-10-06T21:14:00.017185 #12980] DEBUG -- net.ssh.authentication.agent[3fe6314eb07c]: sending agent request 11 len 0 D, [2014-10-06T21:14:00.017231 #12980] DEBUG -- net.ssh.authentication.agent[3fe6314eb07c]: received agent packet 12 len 5 D, [2014-10-06T21:14:00.017260 #12980] DEBUG -- net.ssh.authentication.session[3fe6314d7130]: trying password E, [2014-10-06T21:14:00.017302 #12980] ERROR -- net.ssh.authentication.session[3fe6314d7130]: all authorization methods failed (tried none, publickey, password)

ssh 时出错了,先命令行下试试 ssh,成功了之后再 cap

ssh 是成功的,所以不知道哪個階段出錯了

我在想是不是 bitbucket 那出錯了

我是带 key 使用 cap 的,没想到还是需要 prompt 密码,真是奇怪

改出现这个了 DEBUG[1bcd15fc] Finished in 0.110 seconds with exit status 129 (failed).

两个点,本机对 bitbucket 的公钥,本机对 ssh 服务器的公钥

cd .ssh
ls -lh
config
environment
id_rsa
id_rsa.pub(bitbucket的)
id_rsa_thecampus
id_rsa_thecampus.pub(ssh服务器的)
known_hosts

config 文件

Host bitbucket.org
  IdentityFile ~/.ssh/id_rsa

Host ip
  IdentityFile ~/.ssh/id_rsa_thecampus

希望能帮到你

補充一下 log Exception while executing on host XX.XX.XX.XX:exit .rvm/gems/ruby-2.0.0-p451/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:in exit'.rvm/gems/ruby-2.0.0-p451/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:28:inblock (4 levels) in ' .rvm/gems/ruby-2.0.0-p451/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'

我叫铁锤

列出你的 Gemfile.lock

GEM remote: http://rubygems.org/ specs: actionmailer (4.0.2) actionpack (= 4.0.2) mail (~> 2.5.4) actionpack (4.0.2) activesupport (= 4.0.2) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) activemodel (4.0.2) activesupport (= 4.0.2) builder (~> 3.1.0) activerecord (4.0.2) activemodel (= 4.0.2) activerecord-deprecated_finders (~> 1.0.2) activesupport (= 4.0.2) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) activerecord-session_store (0.1.0) actionpack (>= 4.0.0, < 5) activerecord (>= 4.0.0, < 5) railties (>= 4.0.0, < 5) activesupport (4.0.2) i18n (~> 0.6, >= 0.6.4) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) annotate (2.5.0) rake arel (4.0.2) aws-sdk (1.52.0) aws-sdk-v1 (= 1.52.0) aws-sdk-v1 (1.52.0) json (~> 1.4) nokogiri (>= 1.4.4) bcrypt-ruby (3.1.2) bootstrap-sass (3.1.1.1) sass (~> 3.2) builder (3.1.4) capistrano (3.2.1) i18n rake (>= 10.0.0) sshkit (~> 1.3) capistrano-bundler (1.1.3) capistrano (~> 3.1) sshkit (~> 1.2) capistrano-ext (1.2.1) capistrano (>= 1.0.0) capistrano-rails (1.1.2) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rvm (0.1.1) capistrano (~> 3.0) sshkit (~> 1.2) ckeditor (4.0.11) mime-types orm_adapter (~> 0.5.0) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.4) climate_control (>= 0.0.3, < 1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) coffee-script (2.2.0) coffee-script-source execjs coffee-script-source (1.7.0) colorize (0.7.3) erubis (2.7.0) execjs (2.2.1) hike (1.2.3) i18n (0.6.9) jbuilder (1.5.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) jquery-fileupload-rails (0.4.1) actionpack (>= 3.1) railties (>= 3.1) jquery-rails (3.1.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) mini_portile (0.6.0) minitest (4.7.5) multi_json (1.10.1) mysql2 (0.3.16) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.1) newrelic_rpm (3.9.4.245) nokogiri (1.6.2.1) mini_portile (= 0.6.0) orm_adapter (0.5.0) paperclip (4.1.1) activemodel (>= 3.0.0) activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types polyglot (0.3.5) pr_geohash (1.0.0) protected_attributes (1.0.7) activemodel (>= 4.0.1, < 5.0) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) rails (4.0.2) actionmailer (= 4.0.2) actionpack (= 4.0.2) activerecord (= 4.0.2) activesupport (= 4.0.2) bundler (>= 1.3.0, < 2.0) railties (= 4.0.2) sprockets-rails (~> 2.0.0) railties (4.0.2) actionpack (= 4.0.2) activesupport (= 4.0.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) rdoc (4.1.1) json (~> 1.4) rsolr (1.0.10) builder (>= 2.1.2) s3_direct_upload (0.1.7) coffee-rails (>= 3.1) jquery-fileupload-rails (~> 0.4.1) rails (>= 3.1) sass-rails (>= 3.1) sass (3.2.19) sass-rails (4.0.3) railties (>= 4.0.0, < 5.0) sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) sdoc (0.4.0) json (~> 1.8) rdoc (~> 4.0, < 5.0) simple_captcha2 (0.2.2) rails (>= 3.1, < 4.1) sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sprockets-rails (2.0.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) sqlite3 (1.3.9) sshkit (1.5.1) colorize net-scp (>= 1.1.2) net-ssh (>= 2.8.0) sunspot (2.1.1) pr_geohash (~> 1.0) rsolr (~> 1.0.7) sunspot_rails (2.1.1) nokogiri rails (>= 3) sunspot (= 2.1.1) sunspot_solr (2.1.1) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) turbolinks (2.2.2) coffee-rails tzinfo (0.3.39) uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0)

PLATFORMS ruby

DEPENDENCIES activerecord-session_store annotate (= 2.5.0) aws-sdk bcrypt-ruby (= 3.1.2) bootstrap-sass (~> 3.1.1) capistrano (~> 3.2.1) capistrano-ext (~> 1.2.1) capistrano-rails (~> 1.1.2) capistrano-rvm (~> 0.1.1) ckeditor (= 4.0.11) coffee-rails (~> 4.0.0) jbuilder (~> 1.2) jquery-rails kaminari (= 0.15.1) mysql2 newrelic_rpm paperclip (= 4.1.1) protected_attributes (= 1.0.7) rails (= 4.0.2) s3_direct_upload sass-rails (~> 4.0.0) sdoc simple_captcha2 sqlite3 sunspot_rails (= 2.1.1) sunspot_solr (= 2.1.1) turbolinks uglifier (>= 1.3.0)

服务器上 ssh pub key 是存在哪个目录下面的哪个文件?

我想应该是因为我的 ssh option 里面,分不清哪个 key 是给 bitbucket,哪个 key 是给 server 用的,但是我现在还没搞清楚如何个别设定

#12 楼 @jossjoss54 试试 ssh-add ~/.ssh/key-name

#12 楼 @jossjoss54 config 啊,上面列出来了

#14 楼 @flowerwrong 谢谢。因为我原来没用过 config,后来才知道。

#14 楼 @flowerwrong 不過我 touch config 以後,也重启了 ssh,但是依然跑同样的错误,不过我是在本机加入的。

#14 楼 @flowerwrong 貌似 production.rb 里面的 ssh_option 是预设给 repo_url 用的,那哪里的是给 server 用的呢?

#14 楼 @flowerwrong Running /usr/bin/env git ls-remote -h [email protected]:yuyetigertiger/tigertiger.git on xx.xx.xx.xx

接下来就是 status 128 错误了,我想是找 key 的路径依然错误,但是我有写 config 了

即便我加入了 scm_user 及 scm_password 也依然失败

我觉得你先不要忙 capitrano,第一步只配置 bitbuctet 的 ssh,官方有教程,commit 不用输入用户名密码就算成功,ssh -T bitbucket.org 也行。第二部配置服务器的 ssh,网上教程也不少,注意 config 写法,我上面写的很简略,但是可以用,ssh username@ip,直接进入就算成功。第三部在来搞 cap.

21 楼 已删除

谢谢,不过我的 ssh -T [email protected] 一直是没问题的,使用者也是正确显示。 而且在 deploy.rb 及 deploy/production.rb 各加入了 set :forward_agent, true config 也加入了 ForwardAgent yes 但是仍然显示 DEBUG[68165807] Finished in 126.481 seconds with exit status 128 (failed). D, [2014-10-09T11:02:36.608461 #16765] DEBUG -- tcpsocket[3fde3e2616bc]: received packet nr 71 type 95 len 140 I, [2014-10-09T11:02:36.608510 #16765] INFO -- net.ssh.connection.session[3fde3e17e1a0]: channel_extended_data: 7 1 109b DEBUG[68165807] ssh: connect to host bitbucket.org port 22: Connection timed out DEBUG[68165807] fatal: The remote end hung up unexpectedly DEBUG[68165807] Finished in 126.481 seconds with exit status 128 (failed).

解决了,感谢大家

不知道那边出了问题。。。 DEBUG[abfcd0b2] Tasks: TOP => assets:precompile D, [2014-10-15T15:55:35.554321 #1667] DEBUG -- tcpsocket[3fd75d88fcb0]: received packet nr 1275 type 94 len 76 I, [2014-10-15T15:55:35.554378 #1667] INFO -- net.ssh.connection.session[3fd75c53a73c]: channel_data: 59 47b DEBUGabfcd0b2 D, [2014-10-15T15:55:35.603252 #1667] DEBUG -- tcpsocket[3fd75d88fcb0]: read 36 bytes D, [2014-10-15T15:55:35.603431 #1667] DEBUG -- tcpsocket[3fd75d88fcb0]: received packet nr 1276 type 96 len 12 I, [2014-10-15T15:55:35.603502 #1667] INFO -- net.ssh.connection.session[3fd75c53a73c]: channel_eof: 59 D, [2014-10-15T15:55:35.623093 #1667] DEBUG -- tcpsocket[3fd75d88fcb0]: read 104 bytes D, [2014-10-15T15:55:35.623296 #1667] DEBUG -- tcpsocket[3fd75d88fcb0]: received packet nr 1277 type 98 len 44 I, [2014-10-15T15:55:35.623383 #1667] INFO -- net.ssh.connection.session[3fd75c53a73c]: channel_request: 59 exit-status false cap aborted! SSHKit::Runner::ExecuteError: Exception while executing on host ...: rake exit status: 1 rake stdout: Nothing written rake stderr: Nothing written

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