gpt4 book ai didi

ruby-on-rails - 通过 ruby​​ 脚本克隆 bitbucket 存储库时,权限被拒绝(公钥)

转载 作者:太空狗 更新时间:2023-10-29 14:23:54 26 4
gpt4 key购买 nike

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

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

我安装了它并配置了 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

看来,正确的 key 是为 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

最佳答案

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

关于ruby-on-rails - 通过 ruby​​ 脚本克隆 bitbucket 存储库时,权限被拒绝(公钥),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18045716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com