cap deploy突然说身份验证失败了

时间:2014-02-04 16:20:30

标签: git symfony deployment ssh capifony

我使用Capifony几周来一直无故障地部署我的Symfony2应用程序。前几天我运行了cap部署,没有任何作用。我没有改变任何键,或者故意改变任何其他设置。

我正从我的bitbucket repo部署。

我到处检查过文件权限和所有权。

/var/git/.ssh/authorized_keys 权限600用户git

/var/git/.ssh/known_hosts 权限640用户git

/var/git/.ssh/config 权限700用户git:

Host bitbucket.org
 Hostname bitbucket.org
 ForwardAgent yes
 ForwardX11 no
 User git
 IdentityFile /var/git/.ssh/bitbucket_rsa

我可以在bitbucket上使用相同的公钥从本地计算机登录到生产服务器。我尝试过不同的钥匙。

我重新安装了ruby(1.9.3)。我尝试了Capifony 2.4.2,并尝试回到早期版本(2.4.0和Capistrano 2.15.5)。

没有解决问题。

deploy.rb中的

set :repository,  "git@bitbucket.org:username/example.git"
set :scm,         :git

ssh_options[:forward_agent] = true
ssh_options[:verbose] = :debug
ssh_options[:keys] = %w(/var/git/.ssh/bitbucket_rsa)

运行上限部署:检查

* ←[32m2014-02-04 09:20:30 executing `deploy:check'←[0m
* ←[33mexecuting "test -d /var/www/vhosts/example.com/releases"←[0m
servers: ["example.com"] D, 
[2014-02-04T09:20:30.140652 #11708] DEBUG -- net.ssh.transport.session[15bfe8c]: 
establishing connection to example.com:22
D, [2014-02-04T09:20:30.320662 #11708] DEBUG -- net.ssh.transport.session[15bfe8c]:
connection established
I, [2014-02-04T09:20:30.320662 #11708]  INFO -- net.ssh.transport.server_version 
[15bf274]: negotiating protocol version
D, [2014-02-04T09:20:30.469671 #11708] DEBUG -- net.ssh.transport.server_version
[15bf274]: remote is `SSH-2.0-OpenSSH_5.3'
D, [2014-02-04T09:20:30.470671 #11708] DEBUG -- net.ssh.transport.server_version
[15bf274]: local is `SSH-2.0-Ruby/Net::SSH_2.8.0 i386-mingw32'
D, [2014-02-04T09:20:30.530674 #11708] DEBUG -- tcpsocket[15bfb5c]: read 784 bytes
D, [2014-02-04T09:20:30.530674 #11708] DEBUG -- tcpsocket[15bfb5c]: received packet nr 
0 type 20 len 780
I, [2014-02-04T09:20:30.530674 #11708]  INFO -- net.ssh.transport.algorithms[15bb0b0]: 
got KEXINIT from server
I, [2014-02-04T09:20:30.530674 #11708]  INFO -- net.ssh.transport.algorithms[15bb0b0]: 
sending KEXINIT
D, [2014-02-04T09:20:30.531675 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
0 type 20 len 1620
D, [2014-02-04T09:20:30.531675 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 1624 bytes
I, [2014-02-04T09:20:30.531675 #11708]  INFO -- net.ssh.transport.algorithms[15bb0b0]: 
negotiating algorithms
D, [2014-02-04T09:20:30.531675 #11708] DEBUG -- net.ssh.transport.algorithms[15bb0b0]: 
negotiated:
* kex: diffie-hellman-group-exchange-sha1
* host_key: ssh-rsa
* encryption_server: aes128-cbc
* encryption_client: aes128-cbc
* hmac_client: hmac-sha1
* hmac_server: hmac-sha1
* compression_client: none
* compression_server: none
* language_client:
* language_server:
D, [2014-02-04T09:20:30.532675 #11708] DEBUG -- net.ssh.transport.algorithms[15bb0b0]: 
exchanging keys
D, [2014-02-04T09:20:30.532675 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
1 type 34 len 20
D, [2014-02-04T09:20:30.532675 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 24 bytes
D, [2014-02-04T09:20:30.652681 #11708] DEBUG -- tcpsocket[15bfb5c]: read 152 bytes
D, [2014-02-04T09:20:30.652681 #11708] DEBUG -- tcpsocket[15bfb5c]: received 
packet nr 1 type 31 len 148
D, [2014-02-04T09:20:31.893752 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
2 type 32 len 140
D, [2014-02-04T09:20:31.893752 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 144 bytes
D, [2014-02-04T09:20:31.964757 #11708] DEBUG -- tcpsocket[15bfb5c]: read 720 bytes
D, [2014-02-04T09:20:31.964757 #11708] DEBUG -- tcpsocket[15bfb5c]: received packet nr 
2 type 33 len 700
D, [2014-02-04T09:20:31.968757 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
3 type 21 len 20
D, [2014-02-04T09:20:31.968757 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 24 bytes
D, [2014-02-04T09:20:31.968757 #11708] DEBUG -- tcpsocket[15bfb5c]: received packet nr 
3 type 21 len 12
D, [2014-02-04T09:20:31.969757 #11708] DEBUG -- 
net.ssh.authentication.session[15647f4]: beginning authentication of `git'
D, [2014-02-04T09:20:31.969757 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
4 type 5 len 28
D, [2014-02-04T09:20:31.969757 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 52 bytes
D, [2014-02-04T09:20:32.129766 #11708] DEBUG -- tcpsocket[15bfb5c]: read 52 bytes
D, [2014-02-04T09:20:32.129766 #11708] DEBUG -- tcpsocket[15bfb5c]: received packet nr 
4 type 6 len 28
D, [2014-02-04T09:20:32.129766 #11708] DEBUG -- 
net.ssh.authentication.session[15647f4]: trying none
D, [2014-02-04T09:20:32.130766 #11708] DEBUG -- tcpsocket[15bfb5c]: queueing packet nr 
5 type 50 len 44
D, [2014-02-04T09:20:32.130766 #11708] DEBUG -- tcpsocket[15bfb5c]: sent 68 bytes
D, [2014-02-04T09:20:32.290775 #11708] DEBUG -- tcpsocket[15bfb5c]: read 84 bytes
D, [2014-02-04T09:20:32.290775 #11708] DEBUG -- tcpsocket[15bfb5c]: received packet nr 
5 type 51 len 60
D, [2014-02-04T09:20:32.290775 #11708] DEBUG --     
net.ssh.authentication.session[15647f4]: allowed methods: publickey,gssapi-
keyex,gssapi-with-mic,password
D, [2014-02-04T09:20:32.291775 #11708] DEBUG --     
net.ssh.authentication.methods.none[156bb14]: none failed
D, [2014-02-04T09:20:32.291775 #11708] DEBUG -- 
net.ssh.authentication.session[15647f4]: trying publickey
D, [2014-02-04T09:20:32.291775 #11708] DEBUG -- net.ssh.authentication.agent[15a9f68]: 
connecting to ssh-agent
E, [2014-02-04T09:20:32.292775 #11708] ERROR -- net.ssh.authentication.agent[15a9f68]: 
could not connect to ssh-agent
D, [2014-02-04T09:20:32.292775 #11708] DEBUG -- 
net.ssh.authentication.session[15647f4]: trying password
E, [2014-02-04T09:20:32.292775 #11708] ERROR -- 
net.ssh.authentication.session[15647f4]: all authorization methods failed (tried none, 
publickey, password)
connection failed for: example.com (Net::SSH::AuthenticationFailed: Authentication 
failed for user git@example.com)

我错过了什么?我疯了,试图解决这个问题。

感谢您的帮助。

4 个答案:

答案 0 :(得分:3)

capistrano / capifony(net_ssh更精确)尝试使用不存在的代理连接到服务器,因此失败。

删除...

ssh_options[:forward_agent] = true

...并添加

ssh_options[:use_agent] = false

您没有使用代理(存储您的密钥,ssh可以查询的进程)来连接到服务器...这意味着您无法转发它。您正在提供连接的公钥:

ssh_options[:keys] = %w(/var/git/.ssh/bitbucket_rsa)

答案 1 :(得分:3)

我也有同样的问题。我已按照以下步骤修复了它。

 >> gem uninstall net-ssh -v 2.8.0
 >> gem install net-ssh -v 2.7.0

现在,当我调用“cap”方法时,它完美无缺,并要求我输入密码。

答案 2 :(得分:1)

我认为这是forward_agent选项,但可能是这样:

  

使用ssh-agent管理Bitbucket使用列表中的第一个键。如果您仍然遇到问题,请尝试删除除了您要连接的身份之外的所有身份

在这里找到: https://confluence.atlassian.com/display/BITBUCKET/Troubleshoot+SSH+Issues

我必须摆脱ssh_options [:keys] =%w(/var/git/.ssh/bitbucket_rsa)并使用在bitbucket_rsa之前已经加载的默认id_rsa。

答案 3 :(得分:0)

我的问题是:

我没有在目标服务器的id_rsa.pub中添加我的~/.ssh/authorized_keys密钥。添加密钥后就可以使用!