无法使用部署密钥(bitbucket)EC2进行克隆

ako*_*ian 3 git ssh bitbucket amazon-ec2

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

  1. 我删除了我在bitbucket帐户中的现有部署密钥
  2. ~/.ssh/know_hosts按照/sf/answers/1856447701/进行了清理
  3. 我按照这些步骤生成了我的新密钥 ,并将其作为部署密钥添加到repo中.
  4. 这是输出 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

  5. 但是当我尝试克隆存储库时,
    sudo git clone git@bitbucket.org: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.

我在这里错过了什么吗?有人有什么建议吗?

谢谢阅读.

ako*_*ian 9

这是令人尴尬的,这里的问题是我以sudo用户身份运行命令.

sudo git clone git@bitbucket.org:username/repository.git 
Run Code Online (Sandbox Code Playgroud)

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

此外,在此过程中,我的ssh键似乎已重置,因此请确保ssh -T git@bitbucket.org按预期工作.如果没有,跑步

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

为我工作.更多细节