4

经过几个小时的问题,大量的谷歌搜索和许多配置更改,我请求您帮助我。

我想将 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
4

1 回答 1

1

好的,几天后我自己找到了解决方案。由于配置错误,我的 rails 应用程序没有以 www-data 用户身份运行。出于测试目的,我将实际运行脚本的用户的 ssh-key 添加到我的 bitbucket 存储库中,并且它可以工作。

于 2013-08-06T13:14:51.900 回答