2013-08-04 42 views
3

幾個小時後出現問題,很多googlin和許多配置更改,我請你幫我解決。權限被拒絕(publickey),當通過ruby-script克隆bitbucket存儲庫

我想使用Redmine Bitbucket插件https://bitbucket.org/steveqx/redmine_bitbucket用於在Ubuntu 12.04服務器上運行的Redmine 2.3服務器用於我的私人回購。

我安裝了它並配置了Bitbucket,使POST請求成功地更新本地回購。但我得到以下錯誤:

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"] 

因爲我運行管理平臺與mod_passenger我添加了該用戶的SSH密鑰下/var/www/.ssh/id_rsa

當我運行

sudo -u www-data git clone [email protected]:xxxxxxx/yyyyyyyyy.git 

它的工作原理。當我運行

sudo -u www-data ssh -vvv [email protected] pwd 2> >(grep -i offer) 

我得到:

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

如此看來,右鍵用於www數據的用戶。

這裏北京時間的production.log的全部輸出到位桶POST請求後:

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) 

可能有人請給我一個提示,我在做什麼錯?如果您需要更多數據或痕跡,請告訴我。提前致謝。

編輯: 我/var/www/.ssh/config使用的配置文件:

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

回答

0

好,天后我找到了解決辦法我自己。由於配置錯誤,我的Rails應用程序未作爲www-data用戶運行。出於測試目的,我添加了實際運行腳本的用戶的ssh-key到我的bitbucket存儲庫並且工作。

相關問題