我在过去为其他项目做了几次这样的事情,并最终让它工作,但每次我似乎都无法完全记得该怎么做。橡胶capistrano从bitbucket部署到ec2获取权限被拒绝
我有一台ec2 ubuntu服务器,正在部署capistrano并使用橡胶来设置evertyhing。
在我的ec2服务器上,我生成了ssh密钥,添加到了bitbucket(在我的帐户下,ssh密钥,起初我在项目和部署密钥下尝试过,但这也不起作用)。在我的ec2服务器上,我可以成功手动ssh并直接将我的repo复制到我的家中。我已将密钥添加到ssh代理。
如果我不使用scm并将deploy_via设置为:copy,我可以部署得很好。我相信这抓住了我的本地项目并部署它。
我读过这些:https://confluence.atlassian.com/display/BITBUCKET/Using+Deployment+Keys https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues https://confluence.atlassian.com/pages/viewpage.action?pageId=270827678
这工作得很好:
[email protected]:~$ ssh -T [email protected]
conq: logged in as myBitBucketUser.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
这里的错误信息部署过程中出现了:
* executing "if [ -d /mnt/myProject-production/shared/cached-copy ]; then cd /mnt/myProject-production/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard f2b5b8b6cd1c7835d020d66fdc09b42b2870561e && git clean -q -d -x -f; else git clone -q [email protected]:myRepo.git /mnt/myProject-production/shared/cached-copy && cd /mnt/myProject-production/shared/cached-copy && git checkout -q -b deploy f2b5b8b6cd1c7835d020d66fdc09b42b2870561e; fi"
servers: ["production.myserver.com"]
[production.myserver.com] executing command
** [production.myserver.com :: out] Permission denied (publickey).
** fatal: The remote end hung up unexpectedly
这里是我的部署。 rb:
set :rails_env, Rubber.env
on :load do
set :application, rubber_env.app_name
set :runner, rubber_env.app_user
set :deploy_to, "/mnt/#{application}-#{Rubber.env}"
set :copy_exclude, [".git/*", ".bundle/*", "log/*", ".rvmrc"]
end
# Use a simple directory tree copy here to make demo easier.
# You probably want to use your own repository for a real app
#set :scm, :none
#set :repository, "."
#set :deploy_via, :copy
ssh_options[:forward_agent] = true # also tried false
set :repository, "[email protected]:myProject.git"
set :scm, "git"
set :deploy_via, :remote_cache
set :branch, 'master'
# Easier to do system level config as root - probably should do it through
# sudo in the future. We use ssh keys for access, so no passwd needed
set :user, 'root'
set :password, nil
# Use sudo with user rails for cap deploy:[stop|start|restart]
# This way exposed services (mongrel) aren't running as a privileged user
set :use_sudo, false # also tried true
啊,我认为你正在做点什么。用户部署是root用户,并且我为用户'ubuntu'获取了ssh密钥。我添加了root ssh密钥(通过登录到[email protected]并执行ssh-keygen,然后将id_rsa.pub添加到我的项目的部署密钥中,然后添加到bitbucket中),现在它可以工作!祝贺它。 – Danny 2013-02-16 00:31:56