【发布时间】:2018-03-06 07:29:30
【问题描述】:
我有一个 Rails 5 和 Capistrano 3 应用程序。
我可以将代码推送到 git 存储库,也可以从那里提取它。
但是,当我尝试通过 Capistrano 将代码部署到 (DigitalOcean) 服务器时,我收到以下错误消息:
00:02 git:check
01 git ls-remote git@bitbucket.org:username/reponame.git HEAD
01 repository access denied.
01 fatal: Could not read from remote repository.
01
01 Please make sure you have the correct access rights
01 and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer@IP: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Tasks: TOP => deploy:check => git:check
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer@IP: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
** DEPLOY FAILED
我做了什么:我在我的 mac 上生成了一个新的 SSH 密钥,输出在名为 project_name 和 project_name.pub 的文件中。然后我运行了这个命令:
cat ~/.ssh/project_name.pub | pbcopy
并将此密钥代码粘贴到 Bitbucket 存储库的“SSH 密钥”部分的设置中。
在 Capistrano 配置文件中,我有以下内容:
set :ssh_options, {
keys: %w(/Users/my_name/.ssh/project_name),
forward_agent: true,
auth_methods: %w(publickey password),
port: 22
}
当我运行cap production deploy 时,我被要求输入密码,然后由于上述错误(Please make sure you have the correct access rights and the repository exists.),部署过程失败。
如何正确设置密钥/修复部署问题?
【问题讨论】:
-
您是否能够在没有 capistrano 的情况下从 Digital Ocean 机器读取存储库?因为事实上,是访问您的存储库而不是您的计算机的 Digital Ocean 机器。因此,您需要将服务器 SSH id 作为您的 bitbucket 存储库中的部署密钥。
-
是的,当我登录DigitalOcean服务器并运行
git clone ...时,存储库将成功克隆到服务器上。但如果我尝试通过 Capistrano 部署代码,则会失败。 -
您在使用与 capistrano 相同的用户?
标签: ruby-on-rails git ssh capistrano capistrano3