我们可以看到远程仓库中还有一个SSH的地址,因此我们也可以使用SSH进行访问。
具体操作如下:
--进入当前用户的家目录
ZhangJY@MSI MINGW64 /d/MyWork/Git-Space/SH0720 (master)
$ cd
--删除.ssh目录
ZhangJY@MSI MINGW64 ~
$ rm -rvf .ssh
removed '.ssh/known_hosts'
removed directory '.ssh'
--运行命令生成.ssh秘钥目录[注意:这里-C这个参数是大写的C]
ZhangJY@MSI MINGW64 ~
$ ssh-keygen -t rsa -C atguiguyueyue@aliyun.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/ZhangJY/.ssh/id_rsa):
Created directory '/c/Users/ZhangJY/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/ZhangJY/.ssh/id_rsa.
Your public key has been saved in /c/Users/ZhangJY/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:7CPfRLITKcYDhaqpEDeok7Atvwh2reRmpxxOC6dkY44 atguiguyueyue@aliyun.com
The key's randomart image is:
+---[RSA 2048]----+
| .. |
| .. |
| . .. |
|+ + o . . |
|oO . = S . |
|X . .. + = |
|+@ * .. = . |
|X.&o+. o = |
|Eo+Oo . . |
+----[SHA256]-----+
--进入.ssh目录查看文件列表
ZhangJY@MSI MINGW64 ~
$ cd .ssh
ZhangJY@MSI MINGW64 ~/.ssh
$ ll -a
total 21
drwxr-xr-x 1 ZhangJY 197609 0 11月 25 19:27 ./
drwxr-xr-x 1 ZhangJY 197609 0 11月 25 19:27 ../
-rw-r--r-- 1 ZhangJY 197609 1679 11月 25 19:27 id_rsa
-rw-r--r-- 1 ZhangJY 197609 406 11月 25 19:27 id_rsa.pub
--查看id_rsa.pub文件内容
ZhangJY@MSI MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRXRsk9Ohtg1AXLltsuNRAGBsx3ypE1O1Rkdzpml1woa6y6G62lZri3XtCH0F7GQvnMvQtPISJFXXWo+jFHZmqYQa/6kOIMv2sszcoj2QtwllGXTPn/4T2h/cHjSHfc+ks8OYP7OWOOefpOCbYY/7DWYrl89k7nQlfd+A1FV/vQmcsa1LP5ihqjpjms2CoUUen8kZHbjwHBAHQHWRE+Vc371MG/dwINvCi8n7ibI86o2k0dW0+8SL+svPV/Y0G9m+RAqgec8b9U6DcSSAMH5uq4UWfnAcUNagb/aJQLytrH0pLa8nMv3XdSGNNoAGBFeW2+K81XrmkP27FrLI6lDef atguiguyueyue@aliyun.com
--复制id_rsa.pub文件内容,登录GitHub,点击用户头像→Settings→SSH and GPG keys
接下来再往远程仓库push东西的时候使用SSH连接就不需要登录了。