使用Cap拒绝公钥,但我可以ssh到github

时间:2013-07-03 20:15:17

标签: deployment ssh sinatra capistrano

所以我和卡皮斯特拉诺进行了很多摔跤,而且我觉得我总是要部署它。

我现在遇到的问题是做cap deploy给了我:

Chintan at mbp in ~/Documents/Work/faxattach on master!
± cap deploy
/Users/Chintan/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.2.3/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
    triggering load callbacks
  * 2013-07-03 16:13:56 executing `staging'
    triggering start callbacks for `deploy'
  * 2013-07-03 16:13:56 executing `multistage:ensure'
  * 2013-07-03 16:13:56 executing `deploy'
  * 2013-07-03 16:13:56 executing `deploy:update'
 ** transaction: start
  * 2013-07-03 16:13:56 executing `deploy:update_code'
    executing locally: "git ls-remote git@github.com:chintanparikh/faxattach.git HEAD"
    command finished in 611ms
  * executing "git clone -q git@github.com:chintanparikh/faxattach.git /srv/www/faxattach/releases/20130703201357 && cd /srv/www/faxattach/releases/20130703201357 && git checkout -q -b deploy a237b155f1fe4acef23ad4b594749c567a213117 && (echo a237b155f1fe4acef23ad4b594749c567a213117 > /srv/www/faxattach/releases/20130703201357/REVISION)"
    servers: ["faxattach-staging-new"]
    [faxattach-staging-new] executing command
 ** [faxattach-staging-new :: out] Permission denied (publickey).
 ** [faxattach-staging-new :: out] fatal: The remote end hung up unexpectedly
    command finished in 1286ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /srv/www/faxattach/releases/20130703201357; true"
    servers: ["faxattach-staging-new"]
    [faxattach-staging-new] executing command
    command finished in 572ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327@faxattach' -c 'git clone -q git@github.com:chintanparikh/faxattach.git /srv/www/faxattach/releases/20130703201357 && cd /srv/www/faxattach/releases/20130703201357 && git checkout -q -b deploy a237b155f1fe4acef23ad4b594749c567a213117 && (echo a237b155f1fe4acef23ad4b594749c567a213117 > /srv/www/faxattach/releases/20130703201357/REVISION)'" on faxattach-staging-new

但是,如果我手动ssh到我的服务器然后执行ssh -vT git@github.com,它可以正常工作:

faxattach at ip-10-164-71-243 in ~
○ ssh -vT git@github.com
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /home/faxattach/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/faxattach/.ssh/id_rsa-cert type -1
debug1: identity file /home/faxattach/.ssh/id_dsa type -1
debug1: identity file /home/faxattach/.ssh/id_dsa-cert type -1
debug1: identity file /home/faxattach/.ssh/id_ecdsa type -1
debug1: identity file /home/faxattach/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/faxattach/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/faxattach/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([204.232.175.90]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command: gerve chintanparikh c3:ff:25:e1:30:be:c7:37:51:b5:87:7c:46:dc:c0:c7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command: gerve chintanparikh c3:ff:25:e1:30:be:c7:37:51:b5:87:7c:46:dc:c0:c7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
Hi chintanparikh! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2816, received 2984 bytes, in 0.1 seconds
Bytes per second: sent 33714.5, received 35725.9
debug1: Exit status 1

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

将其添加到config / deploy.rb

set :ssh_options, { :forward_agent => true }

如果您使用自己的私钥进行git,则需要告诉Capistrano使用此命令进行代理转发。代理转发可以使密钥管理更加简单,因为它使用本地密钥而不是服务器上安装的密钥。 资料来源:Agent Forwarding Topic.

并确保用户在config / deploy.rb中不是sudo:

set :use_sudo, false

与您附加的日志一样,您以faxattach(可能不是sudo)身份登录。

答案 1 :(得分:1)

失败的ssh连接是针对服务器的,而不是针对github的。 您应该检查是否可以使用此密钥进入服务器。 如果不是,则应将公钥添加到服务器.ssh / authorized_keys。

同时检查服务器的用户是否正确且存在。