Windows下配置github的ssh

来源:互联网 发布:为什么不能登录淘宝网 编辑:程序博客网 时间:2024/04/30 07:28

废话

当你看到这篇文章的时候应该已经是在配置过程中出现了问题 , 再或者是你还没开始配置….如果是后者…那么恭喜你 , 我为你节省了至少1个小时的时间 . (吐槽 : 网上那些写的头头是道的你们真的配置成功了??)

配置

在配置github SSH的时候出现了很多莫名的错误 , 不是kuow_hosts没有被自动创建 , 就是Permission denied (publickey). 搜了很多资料 , 最后发现github就提供了配置文档………..无语呀……下面是配置过程:


打开Git Bash

注意是Git Bash 不是别的 ……这里我吃亏了……


检查

ls -al ~/.ssh
检查你之前是否用过SSH key 如果没有 继续下一步 , 如果有或者有问题 , 就到C:\Users\Name.ssh下删掉 . (确保已有的key是没用的情况下)


生成你的SSH key文件

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这里需要你进行操作 :
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [按回车]
Enter passphrase (empty for no passphrase): [设置一个密码]
Enter same passphrase again: [确认密码]


加入代理

其实就是生成kuow_hosts 文件

eval $(ssh-agent -s)ssh-add ~/.ssh/id_rsa

配置你的GitHub SSH

clip < ~/.ssh/id_rsa.pub
将公钥拷贝到你的剪切板
登录你的GitHub , 头像 - Settings - SSH and GPG keys - NewSSH key或者 Add SSH key
Title随便填 , 然后移到下面的框中 , 直接ctrl C


测试你是否配置成功

ssh -T git@github.com

会出现如下信息 , 当然输入yes

The authenticity of host 'github.com (192.30.252.1)' 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)?

然后….

Hi username! You've successfully authenticated, but GitHub does notprovide shell access.

使用

检查

首先查看你的用户名是否正确

$ git config user.name

如果显示跟你刚才配置SSH时候输入的 :
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Email一样 , 则正确 , 否则:

$ git config --global user.name "username"

配置你的用户名 .

1 0
原创粉丝点击