1、下载gitwin7客户端
2、打开 “Git bash” 工具,初始化注册的 git账号,邮箱
$ ssh-keygen -t rsa -C "462558306@qq.com" //462558306@qq.com指的是github的邮箱,也可以缺省一路回车即可
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:C6ub9JiJ8jlLDd4siI5DqCzbWG0btIItKQmhZ9X0m40 462558306@qq.com
The key‘s randomart image is:
+---[RSA 2048]----+
| . |
| o . |
|. . . . |
|.. . = |
|+ + . . E . |
|+@ B . o . |
|% B X . . |
|OB.B X |
|=**oO.. |
+----[SHA256]-----+
从上面的输出可一直私钥和公钥的位置
3、将公钥上传到对应的服务器
3.1 网页端的github
在win7中进入 /c/Users/Administrator/.ssh/ 目录,,文本编辑器打开id_rsa.pub,将内容复制,然后打开git的设置ssh界面,粘贴进去保存即可
3.2 自建的github服务器
将文件 /c/Users/Administrator/.ssh/id_rsa.pub 拷贝出来,放到linux服务器的访问用户下面的 .ssh 目录下面(有点,这个是目录,没有就创建一个),然后将 id_rsa.pub文件的内容追加到 authorized_keys 里面
$ cat id_rsa.pub >> .ssh/authorized_keys