权限被拒绝(publickey),当通过ruby-script克隆bitbucket存储库时

时间:2013-08-04 17:41:40

标签: ruby-on-rails git ssh redmine bitbucket

经过几个小时的问题,很多googlin'以及许多配置更改我都要求你帮我解决。

我想将Redmine Bitbucket插件https://bitbucket.org/steveqx/redmine_bitbucket用于在Ubuntu 12.04服务器下运行的Redmine 2.3服务器,用于我的私人存储库。

我安装了它并配置了Bitbucket以成功发出更新本地存储库的POST请求。但我得到以下错误:

BitbucketPlugin: Command 'git clone --mirror git@bitbucket.org:xxxxxxx/yyyyyyyy.git bitbucket_repos/projectxyz/xxxxxxx/yyyyyyyyy' didn't exit properly. Full output: ["Cloning into bare repository 'bitbucket_repos/projetxyz/xxxxxxx/yyyyyyyyy'...\n", "Permission denied (publickey).\r\n", "fatal: The remote end hung up unexpectedly\n"]

因为我正在使用mod_passenger运行Redmine,所以我在/var/www/.ssh/id_rsa

下为该用户添加了一个ssh-key

当我跑步时

sudo -u www-data git clone git@bitbucket.org:xxxxxxx/yyyyyyyyy.git

它有效。我跑的时候

sudo -u www-data ssh -vvv git@bitbucket.org pwd 2> >(grep -i offer)

我明白了:

debug1: Offering RSA public key: /var/www/.ssh/id_rsa

所以看起来,右键用于www-data用户。

这是来自bitbucket的POST请求之后的production.log的完整输出:

Started POST "/bitbucket_service?project_id=projectxy" for 131.103.20.166 at 2013-08-04 

19:27:12 +0200
Processing by BitbucketServiceController#index as HTML
  Parameters: {"payload"=>"{\"repository\": {\"website\": \"\", \"fork\": false, \"name\": \"yyyyyyyy\", \"scm\": \"git\", \"owner\": \"xxxxxxx\", \"absolute_url\": \"/xxxxxxx/yyyyyyyy/\", \"slug\": \"yyyyyyyy\", \"is_private\": true}, \"truncated\": false, \"commits\": [{\"node\": \"2d43ec2ad9f3\", \"files\": [{\"type\": \"modified\", \"file\": \"app/controllers/notifications_controller.rb\"}], \"branch\": \"master\", \"utctimestamp\": \"2013-08-04 17:28:33+00:00\", \"timestamp\": \"2013-08-04 19:28:33\", \"raw_node\": \"2d43ec2ad9f3cc2cfbc0190adb14c7e5683df22d\", \"message\": \"Testing on redmine Repo\\n\", \"size\": -1, \"author\": \"xxxxxxx\", \"parents\": [\"0153d1ce7f9f\"], \"raw_author\": \"My Name <my@mail.com>\", \"revision\": null}], \"canon_url\": \"https://bitbucket.org\", \"user\": \"xxxxxxx\"}", "project_id"=>"projectxyz"}
  Current user: anonymous
BitbucketPlugin: Command 'git clone --mirror git@bitbucket.org:xxxxxxx/yyyyyyyy.git bitbucket_repos/projectxyt/xxxxxxx/yyyyyyyy' didn't exit properly. Full output: ["Cloning into bare repository 'bitbucket_repos/projectxyz/xxxxxxx/yyyyyyyy'...\n", "Permission denied (publickey).\r\n", "fatal: The remote end hung up unexpectedly\n"]
  Rendered text template (0.0ms)
Completed 500 Internal Server Error in 1257ms (Views: 1.3ms | ActiveRecord: 2.6ms)

有人可以给我一个提示,我做错了什么?如果您需要更多数据或痕迹,请告诉我们。提前谢谢。

修改 我在/var/www/.ssh/config中使用配置文件:

Host *
    User git
    Hostname bitbucket.org
    PreferredAuthentications publickey
    IdentityFile /var/www/.ssh/id_rsa

1 个答案:

答案 0 :(得分:0)

好的,几天后我找到了解决方案。由于配置错误,我的rails应用程序未作为www-data用户运行。出于测试目的,我添加了用户的ssh-key,它实际上将脚本运行到我的bitbucket存储库并且工作正常。