配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)

由于之前一直在用的机器送去修,最近换了一台新机器,在使用 git push -uorigin master命令提交时报错:

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

查过才发现是没有配置ssh key。所以在重新配置ssh key时简单记录过程,方便以后查找。

1.右键点击git bash。

2.先检查自己电脑上的ssh key,输入cd ~/.ssh到根目录.ssh文件夹下(如果显示No such file or directory 则表明是第一次用git)。

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第1张图片

3.ssh-keygen -t rsa -C  “注册github时所用的邮箱地址”生成新的ssh key。

会出现几处需要输入的字样:

显示:

Generating public/private rsa key pair.

Enter file in which to save the key (/c/Users/Frank/.ssh/id_rsa):回车

/c/Users/Frank/.ssh/id_rsa already exists.

Overwrite (y/n)? y

Enter passphrase (empty for no passphrase):输入密码,作为提交项目的密钥使用,也可以直接回车密码为空,输入密码时没有输入的字样,但实际上已经输入了

Enter same passphrase again:输入密码,为空的话则不用确认,回车

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第2张图片

4.按照红框里的路径找到id_rsa.pub文件,如果按照路径没有找到在文件夹上方“查看”勾选 “文件扩展名”和“隐藏的项目”,打不开使用右键→打开方式→记事本打开。

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第3张图片

5.复制记事本中的内容,打开github主页,在右上角头像下拉框中选setting。

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第4张图片

6.左侧找到SSH&GPG keys。

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第5张图片

7.title可以随便写,将刚刚复制的内容粘贴到key中。

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第6张图片

配置SSH key(报错fatal: Could not read from remote repository.Please make sure you have the correct ac)_第7张图片

8.测试是否配置成功,输入ssh -T [email protected]

中间如果要求输入,输入yes。如果出现红框中的内容,则配置成功。

 

 参考链接:http://codewithzhangyi.com/2018/04/19/如何搭建自己的个人网站(上)/

你可能感兴趣的:(git,ssh,git,github)