1、Windows生成证书ssh
查看是否有生成的证书
默认位置:C:\Users\Administrator.ssh
查找:在Windows下查看[c盘->用户->自己的用户名->.ssh]下是否有"id_rsa、id_rsa.pub"文件,这两个就是证书文件默认名称。
如果有证书可以删除重新生成证书,也可以直接使用原有的证书。
生成证书 ssh-keygen -t rsa
安装好git后:
右击 空白处-->进入 Git Bash Here :邮箱可以不是真实的
$ ssh-keygen -t rsa -C "zhengja@dist.com"
Generating public/private rsa key pair.
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:WDXfBdxE5au0AE0hCIE8u6aaqbQJIS883mBMNs4zm4k zhengja@dist.com
The key's randomart image is:
+---[RSA 2048]----+
| . .oo ..oo...=*|
| + . .+o ..o.|
| o .. .. . .|
| . o . .|
|o+ . . S . . . |
|Oo.o o o |
|o%+ o |
|*=% |
|EB . |
+----[SHA256]-----+
3、查看是否生成证书文件
win证书ssh.png说明:id_rsa:是私钥,id_rsa.pub:是公钥
2、GitHub配置ssh 公钥
4、使用ssh证书
可以配置gitlab、github、其它机器上等。
例如:配置github
获取公钥:打开id_rsa.pub文件
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMXYx0+V6xndjSdHpwOWqtqwQ2Wn95mFemNZuuKcILnqPP/bVJm3RKKmCu7jUqM2YgQOSdOAwdvKHTfKKFVLMXHvbKY63TdlrhvGZSXmsZPRVi3pxz2bZC+Wuxv3feVKypCWuHZBNjrmVylaDA7XcFwFrqH367621O/DIad1QgysXqX1ZhkL9SSlKVSowgyWcNvO3vXRkomg5oxiRCxhcuMsiN+WhJPuynNCMqPSIb/xNmX8lvXB2wTVqEnnlwsy849Mduv6g1I2OipOTUyDcEj8G+Tl4c44bYJKlyYxo7eF0MhZgAVpFBlcU+s/CpZfa4VdoOMehNr8NTUqxYbsmT zhengja@dist.com
复制公钥:id_rsa.pub 内容-->配置github
登录github 点击头像-->settings-->SHH and GPG keys-->New SSH key
github配置ssh的公钥.png测试证书配置是否成功:随便找个github上的项目ssh地址
github ssh地址.png
git@github.com:zhengjiaao/springboot-test-github.git
$ git clone git@github.com:zhengjiaao/springboot-test-github.git
Cloning into 'springboot-test-github'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 81 (delta 21), reused 71 (delta 13), pack-reused 0
Receiving objects: 100% (81/81), 10.66 KiB | 184.00 KiB/s, done.
Resolving deltas: 100% (21/21), done.
能下载成功证明配置的ssh公钥没有问题!
网友评论