首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Capistrano和Bitbucket权限被拒绝

Capistrano和Bitbucket权限被拒绝
EN

Stack Overflow用户
提问于 2016-02-19 17:55:54
回答 2查看 825关注 0票数 1

我正在尝试用我的Rails应用程序来设置capistrano,并使用数字海洋进行托管。

我有一个Ubuntu服务器运行独角兽和nginx。

在这个阶段,我的capistrano部署一直失败:

代码语言:javascript
复制
DEBUG [08cab5b3] Command: cd /home/rails/automata && (     GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/automata/git-ssh.sh /usr/bin/env git     clone --mirror git@bitbucket.org:automata_tech/staging.git     /home/rails/automata/repo )
DEBUG [08cab5b3]        Cloning into bare repository     '/home/rails/automata/repo'...
DEBUG [08cab5b3]        /home/rails/automata/repo: Permission denied
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as     deployer@178.62.4.140: git exit status: 1
git stdout: Nothing written
git stderr: Cloning into bare repository    '/home/rails/automata/repo'...
/home/rails/automata/repo: Permission denied

SSHKit::Command::Failed: git exit status: 1
git stdout: Nothing written
git stderr: Cloning into bare repository    '/home/rails/automata/repo'...
/home/rails/automata/repo: Permission denied

Tasks: TOP => git:create_release => git:update => git:clone
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as     deployer@178.62.4.140: git exit status: 1
git stdout: Nothing written
git stderr: Cloning into bare repository    '/home/rails/automata/repo'...
/home/rails/automata/repo: Permission denied

我在服务器上生成了一个ssh密钥,并将其添加到bitbucket帐户中。

如果我把ssh放到服务器上,然后git克隆回购,那就很好了。

在服务器上运行ssh -T git@bitbucket.org返回:

代码语言:javascript
复制
 logged in as company.

 You can use git or hg to connect to Bitbucket. Shell access is disabled.

staging.rb:

代码语言:javascript
复制
set :ssh_options, {
  forward_agent: true,
  auth_methods: %w(publickey)
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-02-19 18:45:46

在尝试创建目录permission denied时,您的错误消息显示了一个/home/rails/automata/repo错误。换句话说,部署程序用户没有必要的文件权限。它与您的SSH密钥或Bitbucket无关。

只需确保/home/rails/automata存在,并由deployer拥有。为此,您可能需要使用sudo或以root身份登录。

代码语言:javascript
复制
mkdir -p /home/rails/automata
chown deployer /home/rails/automata

顺便说一句,我不确定把你的应用程序放在/home/rails里是有意义的。如果您正在使用deployer部署应用程序(因此也是应用程序的所有者),那么将其放在/home/deployer中是否更有意义呢?还是在像/var/www/automata这样的“中立”位置(默认情况下是卡皮斯特拉诺建议的那样)?

票数 2
EN

Stack Overflow用户

发布于 2016-02-19 18:02:00

在配置/部署/production.rb(或staging.rb)中,需要启用ssh代理转发。

您可以通过将服务器文件更改为包含forward_agent: true来完成此操作。

下面是一个例子:

代码语言:javascript
复制
server 'xxx.xxx.xxx.xxx',
  user: 'deploy',
  roles: %w{web app db},
  ssh_options: {
    forward_agent: true,
    auth_methods: %w(publickey)
  }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35511743

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档