从Bitbucket部署到Digital Ocean - 权限被拒绝(publickey)错误

sam*_*207 4 git capistrano bitbucket ruby-on-rails-4 digital-ocean

我正在尝试将我的Rails应用程序从Bitbucket部署到Digital Ocean.我使用Git作为我的版本控制系统,我做了以下事情:

  1. 抓住我的电脑ssh键 pbcopy < ~/.ssh/id_rsa.pub
  2. 将我的计算机ssh密钥添加到Digital Ocean(https://cloud.digitalocean.com/ssh_keys)
  3. 将我的计算机ssh密钥添加到Bitbucket repo作为部署密钥(https://bitbucket.org/<account name>/<project admin/deploy-keys)

但是当我运行cap deploy它时会出现这个错误

    servers: [<server ip>]
    [<server ip>] executing command
 ** [<server ip> :: out] Permission denied (publickey).
 ** [<server ip> :: out]
 ** [<server ip> :: out] fatal: Could not read from remote repository.
 ** [<server ip> :: out]
 ** [<server ip> :: out]
 ** [<server ip> :: out] Please make sure you have the correct access rights
 ** [<server ip> :: out]
 ** [<server ip> :: out] and the repository exists.
 ** [<server ip> :: out]
Run Code Online (Sandbox Code Playgroud)

这是我的deploy.rb档案

set :scm, "git"
set :repository, "git@bitbucket.org:<user name>/<project name>.git"
set :branch, "master"
Run Code Online (Sandbox Code Playgroud)

如果我clone回到我当地的回购,它运作正常.我浏览了Bitbucket文档,但仍然无法弄清楚缺少什么.

我对Bitbucket的工作是:

ssh -T git@bitbucket.org
authenticated via a deploy key.


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

This deploy key has read access to the following repositories:

<repor name>
Run Code Online (Sandbox Code Playgroud)

发现这个问题,但没有任何运气.

sam*_*207 8

好的,我找到了解决方案,我会在这里添加它,以便有人可能会觉得它很有用.

我修复了我在Digital Ocean中创建SSH密钥并将其添加到Bitbucket的问题.

以下是步骤

  • 在Digital Ocean中创建SSH密钥
  • 将该SSH密钥添加为Digital Ocean SSH密钥
  • 将相同的密钥添加到Bitbucket部署密钥(https://bitbucket.org/<user>/<project>/admin/deploy-keys)