首先要创建SSH Key 需要有git Bash
所以你可以先装好 下载链接 https://git-scm.com/downloads
1. 在你的电脑用户路径下创建一个 .ssh 文件夹
cmd 命令符,打开命令提示符窗口(最好用管理员运行)

输入 mkdir .ssh 创建文件夹。
2. 运行windows 下 cmd 打开 Git Bash 最好用管理员运行;

3. 配置 全局用户名和邮件
git config --global user.name "yourname"
git config --global user.email "youremail@163.com"

4. 然后 准备创建 ssh key
ssh-keygen -t rsa -C "youremail@163.com" (这里是你的邮件 ),会要求你输入自己的passphrase 直接enter

5 .最好成功的话 会输出两个文件 id_rsa 和 id_rsa.pub 就在刚才创建的 .ssh 文件夹中, (类似如下路径)

类似下面的两个文件

现在密钥创建好了, 需要你登陆github把密钥加上去 https://github.com/login
打开你的 用户设置 Account settings

点开 SSH and GPG keys ,新建一个sshkey (New SSH key ) ,

title 随便写,把.ssh文件夹中的id_rsa.pub文件中的内容复制到 Key里面, Add SSH key完成github设置

验证是否成功:
输入 ssh-T youremail@163.com

不成功就是

解决方式是:在 .ssh 文件夹新建一个 config文件
写入以下内容
Host github.com
User youremail@163.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
会出现 Are you sure you want to continue connecting (yes/no)? 直接写 yes
然后再试试
$ ssh -T git@github.com
成功输出 Hi Your Name! You've successfully authenticated, but GitHub does not provide shell access.
就大功告成啦 就可以 fetch pull push
网友评论