2014-12-08 43 views
3

我无法使用我的部署密钥将我的存储库克隆到远程EC2 ubuntu实例。 以下是我遵循的步骤。使用部署密钥(bitbucket)无法克隆EC2

  1. 我删除了现有部署钥匙我在我的帐户到位桶
  2. 我打扫~/.ssh/know_hosts以下https://stackoverflow.com/a/26520681/808734
  3. 我产生我的新的密钥以下these steps 并将其添加为一个deployment key来回购。
  4. 这里是ssh -T [email protected]

    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 protected]

  5. 输出但是当我尝试克隆库
    sudo git clone [email protected]:username/repository.git我收到以下错误 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.

我在这里失去了一些东西?任何人有任何建议?

感谢您的阅读。

回答

9

那么这是尴尬,这里的问题是我运行的命令为sudo用户。

sudo git clone [email protected]:username/repository.git 

这可能是试图以root用户身份克隆存储库并导致错误。但是,作为当前用户进行克隆,并向所需目录提供写入权限,让我可以成功克隆存储库。

另外在此过程中,我的ssh密钥似乎已被重置,因此请确保ssh -T [email protected]按预期工作。如果没有,运行

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

为我工作。 more details

+1

'ssh-add'救了我。即使在我创建了一个新的密钥并尝试了这个密钥之后,我不得不用ssh-add手动添加它。做得好! – Aarmora 2016-05-27 17:27:07

+0

哇!做到了!如果不是问题,请告诉我真正的问题是什么,这段代码做了什么? – BlackBurn027 2017-09-14 14:25:52

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

似乎是很多GIT用户的一个重复发生的问题。

请务必使用正确的用户名和网址!

git: fatal: Could not read from remote repository会有帮助。

Goodluck!

0

如果你是团队的一部分,并试图克隆版本库,那么你可能需要一点即

更改网址

SSH://[email protected] TEAM_NAME/repo_name.git

SSH://[email protected] / TEAM_NAME/repo_name。git

相关问题