Window下git链接github ssh配置

来源:互联网 发布:网贷之家数据分析 编辑:程序博客网 时间:2024/05/21 05:42

1 生成ssh
ssh-keygen -t rsa -C “your_email@youremail.com”

2 保存到指定文件
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Daven/.ssh/id_rsa): 这里要填写文件的完整目录

例如,我们先在d盘下创建一个空文件
d:/ssh/id_rsa

然后上面就应该填写: /d/ssh/id_rsa

3 测试
ssh -T git@github.com
这是会出现下面的问题:Permission denied (publickey)

4 不用着急,解决办法如下:
先运行:ssh-agent bash
如果不运行上面的命令,会出现:Could not open a connection to your authentication agent
然后运行:ssh-add /d/ssh/id_rsa

然后,测试OK

$ ssh -T git@github.com
Hi 。。。! You’ve successfully authenticated, but GitHub does not provide shell access.

然而上面并不是最终的解决办法,因为自己定义一个目录,每次重启都需要ssh-add一下这个ssh key,最好的办法,是按照系统提示,把ssh放在提示的位置,也就是这个/c/Users/Daven/.ssh/id_rsa;
同时配置一个config文件,这样就一劳永逸了。
Host github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_sa

1 0
原创粉丝点击