问题:
在本地(linux系统)下载github仓库源代码时,执行git clone 命令时出现以下报错:
$ git clone git@github.com:hh-hub/prometheus.git
Cloning into 'Prometheus'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决:
这是由于github仓库缺少公钥,把本地的公钥添加到github上即可,操作步骤如下:
1.查看本地公钥,并复制
$ cd ~/.ssh
$ cat id_rsa.pub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2. github 添加本地公钥:Settings -> SSH and GPG keys -> new SSH key ->添加新的公钥并将本地id_rsa.pub里的内容复制到Key中,如下总共四步: