从一台没使用 Git 的电脑上执行 git clone XXXXX 下载代码时候遇到下面这个问题的提示:
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
遇到这个的解决办法如下:
1.配置用户名和邮箱,执行:
git config --global user.name "name"
git config --global user.email "email"
2.生成 RSA key,执行:
ssh-keygen -t rsa -C “email”
注意-C 是大写。
输入上述命令之后连续输入 3 个空格,也可以在输入的过程中根据提示输入密码,不过记得加下输入的密码。操作完后收到以下提示:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ruben/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ruben/.ssh/id_rsa.
Your public key has been saved in /home/ruben/.ssh/id_rsa.pub.
.....
3.Windows 到 C:\Users\你的用户名.ssh,Linux 到/home/用户名/.ssh/目录下打开 id_rsa.pub 文件,将文件里面的内容拷贝下来。登录到 GitHub 账户,通过点击头像-->Settings-->SSH and GPG keys 选项卡中点击 New SSH key,将刚才拷贝的内容粘贴到 key 输入框,并且取一个名字点击“Add SSH key”就将自己的公钥添加到 GitHub 了。ubuntu 到/home 目录下点击 ctrl+H 显示隐藏文件,打开.ssh 目录。
4.执行
ssh git@github.com
可以看到有提示认证成功的信息了。
接下来就可以愉快的使用 GitHub 了。
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于