Reputation: 428
after problems for a few hours, a lot of googlin' and many many configuration changes I'm asking you to help me out.
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.
I installed it and configured Bitbucket to make the POST request for updating the local repos successfully. But i get the following error:
BitbucketPlugin: Command 'git clone --mirror [email protected]: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
When I run
sudo -u www-data git clone [email protected]:xxxxxxx/yyyyyyyyy.git
it works. When I run
sudo -u www-data ssh -vvv [email protected] 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.
Here ist the full output of the production.log after the POST request from bitbucket:
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 <[email protected]>\", \"revision\": null}], \"canon_url\": \"https://bitbucket.org\", \"user\": \"xxxxxxx\"}", "project_id"=>"projectxyz"}
Current user: anonymous
BitbucketPlugin: Command 'git clone --mirror [email protected]: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:
Host *
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile /var/www/.ssh/id_rsa
Upvotes: 4
Views: 5692
Reputation: 428
Okay, after days I found the solution my self. Due to missconfiguration, my rails app was not running as www-data user. For testing purposes I added the ssh-key of the User which actually runs the script to my bitbucket repository and it worked.
Upvotes: 1