SSH KEY:sudo git clone权限被拒绝

med*_*ifi 0 git ssh ssh-keys gitlab

我在我的电脑(ubuntu 16.04)中创建了一个公共ssh密钥,并将其与我的gitlab.com帐户相关联.我用过$ sudo git clone git@gitlab.com:XXXXXX/XXXXXX.git,我有这个错误:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我做了什么:我在我的html文件夹中添加了777 chmod,只使用了命令$ git clone git@gitlab.com:XXXXXX/XXXXXX.git,克隆创建成功.

谁能解释一下我刚刚发生了什么?

mel*_*ene 5

由于你是以gitroot用户身份运行的,大概是它尝试使用root的ssh密钥(如果有的话)登录,而不是你的.