Cannot clone using deployment key (bitbucket) EC2

I cannot clone my repository to my EC2 ubuntu remote instance using my deployment key. Here are the steps I followed.

  • I deleted the existing deployment keys that I had on my bitbucket account.
  • I cleaned it up ~/.ssh/know_hosts

    after stackoverflow question/702163 / ...
  • I created a new key in these steps and added it as a deployment key to the repo.
  • Here is the result ssh -T git@bitbucket.org

    You can use git or hg to connect to Bitbucket. Shell access is disabled. This deploy key has read access to the following repositories: username/repository: KEYNAME -- email@gmail.com

  • But when I try to clone the repository
    sudo git clone git@bitbucket.org:username/repository.git

    I get the following error Cloning into 'repository'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Am I missing something? Anyone have any advice?

Thanks for reading.

+3


source to share


3 answers


Well this is confusing, the problem is I was running the command as a user sudo

.

sudo git clone git@bitbucket.org:username/repository.git 

      

This is probably trying to clone the repository as root and throwing an error. However, cloning as the current user and granting write permissions to the required directory allows me to successfully clone the repository.



Also during the process my ssh key seems to have been reset, so make sure it ssh -T git@bitbucket.org

works as expected. If not, run

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 59566
ssh-add ~/.ssh/id_rsa

      

worked for me. more details

+9


source


fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists.

      

seems like a repetition problem for many GIT users.

Make sure to use the correct username and url!



git: fatal: failed to read from remote repository , might be helpful.

Good luck!

+1


source


If you are part of a team and are trying to clone a repository, you may need to change the URL slightly.

of

SSH: // git @ bitbucket.org : TEAM_NAME / repo_name.git

to

SSH: // git @ bitbucket.org / TEAM_NAME / repo_name.git

0


source







All Articles