Deployment to Digital Ocean by Bitbucket - Access Denied Error (post)

I am trying to deploy a Rails application from Bitbucket to Digital Ocean. I am using Git as my source control system, I did the following:

  • hijack my computers ssh key pbcopy < ~/.ssh/id_rsa.pub

  • add my ssh computers to Digital Ocean ( https://cloud.digitalocean.com/ssh_keys )
  • add ssh keys for my computers to Bitbucket repository as deployment key ( https://bitbucket.org/<account name>/<project admin/deploy-keys

    )

but when i run cap deploy

it gives this error

    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]

      

Here is my deploy.rb

file

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

      

If I clone

repo for my local it works fine. I've gone through the Bitbucket docs but still can't figure out what is missing.

And my ssh for Bitbucket works:

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>

      

Found this SO question , but no luck.

+3


source to share


1 answer


Ok I found a solution, I will add it here so someone can find it useful.

I fixed the problem with generating an SSH key on Digital Ocean and adding it to Bitbucket.



Following are the steps

  • create SSH key in Digital Ocean
  • add that SSH key as Digital Ocean SSH key
  • add same key to Bitbucket deployment key ( https://bitbucket.org/<user>/<project>/admin/deploy-keys

    )
+7


source







All Articles