Gitee和GitHub都 提供了基于 SSH 协议的 Git 服务,在使用 SSH 协议访问仓库之前,需要先配置好仓库的 SSH 公钥。gitee账户公钥请移步 设置账户 SSH 公钥
生成 SSH 公钥
Windows 用户建议使用 Windows PowerShell 或者 Git Bash,在 命令提示符 下无
cat
和ls
命令。
- 通过命令
ssh-keygen
生成 SSH Key:
ssh-keygen -t ed25519 -C "Gitee SSH Key"
-t
key 类型-C
注释
输出,如:
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/git/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_ed25519
Your public key has been saved in /home/git/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:ohDd0OK5WG2dx4gST/j35HjvlJlGHvihyY+Msl6IC8I Gitee SSH Key
The key's randomart image is:
+--[ED25519 256]--+
| .o |
| .+oo |
| ...O.o + |
| .= * = +. |
| .o +..S*. + |
|. ...o o..+* * |
|.E. o . ..+.O |
| . . ... o =. |
| ..oo. o.o |
+----[SHA256]-----+
- 中间通过三次回车键确定
- 查看生成的 SSH 公钥和私钥:
ls ~/.ssh/
id_ed25519 id_ed25519.pub
- 私钥文件
id_ed25519
- 公钥文件
id_ed25519.pub
- 读取公钥文件
~/.ssh/id_ed25519.pub
:
cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAA***5B Gitee SSH Key