git-关联远程git仓库详细步骤-2
阅读原文时间:2023年07月08日阅读:3

1、打开git bash,在控制台中输入以下命令:ssh-keygen -t rsa -C "邮箱地址"

结果:

fanxi@AT8350 MINGW64 ~
$ ssh-keygen -t rsa -C "邮箱地址" 输入命令,后面的是git的邮箱地址,在官网上注册的
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/fanxi/.ssh/id_rsa): /c/Users/fanxi/.ssh/id_rsa 在这个目录下面创建文件目录
/c/Users/fanxi/.ssh/id_rsa already exists.
Overwrite (y/n)? Y
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again:在输入密码
Your identification has been saved in /c/Users/fanxi/.ssh/id_rsa.
Your public key has been saved in /c/Users/fanxi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:UZ6rCceojCdL9oG9cJcl0TFurgaHLcsDK7mk1utwjrI
The key's randomart image is:
+---[RSA 2048]----+
| o . |
| o = . |
| . = o |
| o * . . |
| . + * S . |
| . O * B o |
|ooX.@ = o |
|+*=O * |
|Eoo++ |
+----[SHA256]-----+

上面是正确的结果,注意邮箱输入错误了,生成的密钥不能用

2、查看刚才创建的文件密钥和私钥

fanxi@AT8350 MINGW64 ~
$ cd /c/Users/fanxi/.ssh

fanxi@AT8350 MINGW64 ~/.ssh
$ ls
id_rsa id_rsa.pub 这个目录下面有私钥和密钥

3、复制公钥到git的步骤

fanxi@AT8350 MINGW64 ~/.ssh
$ cat id_rsa.pub 查看公钥
ssh-rsa 后面公钥的字符串

配置公钥:

4、测试密钥是否可用

fanxi@AT8350 MINGW64 ~/.ssh
$ ssh -T git@github.com
Enter passphrase for key '/c/Users/fanxi/.ssh/id_rsa':
Hi git用户名称 You've successfully authenticated, but GitHub does not provi de shell access.

如果可用要是的颜色就变成绿色

终于远程数据库新建成功了,可以本地从远端clone了。