【问题标题】:Deploying to Digital Ocean from Bitbucket - Permission denied (publickey) error从 Bitbucket 部署到 Digital Ocean - 权限被拒绝(公钥)错误
【发布时间】:2014-08-11 13:58:10
【问题描述】:

我正在尝试将我的 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 存储库 (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]

这是我的deploy.rb 文件

set :scm, "git"
set :repository, "git@bitbucket.org:<user name>/<project name>.git"
set :branch, "master"

如果我 clone 将 repo 发送到我的本地,它可以正常工作。我浏览了 Bitbucket 文档,但仍然无法弄清楚缺少什么。

我的 ssh 到 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>

找到了这个SO question,但没有任何运气。

【问题讨论】:

    标签: git ruby-on-rails-4 capistrano bitbucket digital-ocean


    【解决方案1】:

    好的,我找到了解决方案,我将在此处添加它,以便有人会发现它有用。

    我解决了在 Digital Ocean 中创建 SSH 密钥并将其添加到 Bitbucket 的问题。

    以下是步骤

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

    【讨论】:

    • 第一个链接 404 和第二个有一些额外的 /
    【解决方案2】:

    如果您想将额外的 SSH 密钥添加到已经有一些密钥的 Droplet,您需要通过 SSH 启用密码验证才能完成此操作。通过控制面板添加 SSH 密钥只能在创建过程中添加到 Droplet。

    如果您无法使用现有的 SSH 密钥访问机器,则需要使用您的 Droplet 的 Web 控制台执行这些步骤。要启用密码验证,请按照以下步骤操作。

    使用您喜欢的文本编辑器编辑此配置文件。

    /etc/ssh/sshd_config

    找到显示“PasswordAuthentication no”的行并将其更改为“PasswordAuthentication yes”,然后保存并退出编辑器。

    回到命令提示符后,运行以下命令以允许进行新的 SSH 更改。

    /etc/init.d/ssh 重启

    一旦 SSH 重新启动,您可以尝试通过 SSH 连接到您的 droplet。如果您收到权限被拒绝错误,您可能需要使用“passwd”命令更新您的密码。

    当您在计算机上通过 SSH 成功登录服务器后,我建议您按照以下文章中的步骤获取为此 droplet 配置的新 SSH 密钥。

    https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

    希望这些信息对您有所帮助!如果您有任何问题或在此过程中遇到任何问题,请告诉我们!

    【讨论】:

      猜你喜欢
      • 2019-11-23
      • 1970-01-01
      • 2018-03-11
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-09
      • 2020-12-30
      相关资源
      最近更新 更多