[英]Permission denied (publickey), when cloning bitbucket repository via ruby-script
after problems for a few hours, a lot of googlin' and many many configuration changes I'm asking you to help me out. 经过几个小时的问题,很多googlin'以及许多配置变化我都要求你帮助我。
I want to use the Redmine Bitbucket plugin https://bitbucket.org/steveqx/redmine_bitbucket for my Redmine 2.3 Server running under Ubuntu 12.04 Server for my private repos. 我想使用Redmine Bitbucket插件https://bitbucket.org/steveqx/redmine_bitbucket为我的Redbu 2.3服务器在Ubuntu 12.04 Server下运行我的私人回购。
I installed it and configured Bitbucket to make the POST request for updating the local repos successfully. 我安装它并配置Bitbucket以成功发出更新本地存储库的POST请求。 But i get the following error: 但是我收到以下错误:
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"]
Because I'm running Redmine with mod_passenger I added a ssh-key for that user under /var/www/.ssh/id_rsa 因为我用mod_passenger运行Redmine,我在/var/www/.ssh/id_rsa下为该用户添加了一个ssh-key
When I run 我跑的时候
sudo -u www-data git clone git@bitbucket.org:xxxxxxx/yyyyyyyyy.git
it works. 有用。 When I run 我跑的时候
sudo -u www-data ssh -vvv git@bitbucket.org pwd 2> >(grep -i offer)
I get: 我明白了:
debug1: Offering RSA public key: /var/www/.ssh/id_rsa
so it seems, the right key is used for the www-data user. 所以看来,正确的密钥用于www-data用户。
Here ist the full output of the production.log after the POST request from bitbucket: 这是来自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)
Could someone please give me a hint, what I'm doing wrong? 有人可以给我一个提示,我做错了什么? If you need further data or traces, let me know. 如果您需要更多数据或痕迹,请告诉我们。 Thanks in advance. 提前致谢。
Edit: I use a config file in /var/www/.ssh/config: 编辑:我在/var/www/.ssh/config中使用配置文件:
Host *
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile /var/www/.ssh/id_rsa
Okay, after days I found the solution my self. 好的,几天后我找到了解决方案。 Due to missconfiguration, my rails app was not running as www-data user. 由于配置错误,我的rails应用程序未作为www-data用户运行。 For testing purposes I added the ssh-key of the User which actually runs the script to my bitbucket repository and it worked. 出于测试目的,我添加了用户的ssh-key,它实际上将脚本运行到我的bitbucket存储库并且它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.