github远程私密仓库无法拉取

262 阅读1分钟

远程拉取私密出现报错

git clone git@github.com:<用户名>/<项目名>.git
Cloning into '<项目名>'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

在命令行输入ssh-keygen

ssh-keygen

会得到以下提示:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/u1/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/u1/.ssh/id_rsa
Your public key has been saved in /home/u1/.ssh/id_rsa.pub
The key fingerprint is:XXXXXX(密钥)

点击/home/u1/.ssh/id_rsa.pub复制密钥

前往GitHub个人settings

将复制的密钥添加即可

命令行git clone就可拉取代码