git配置SSH 公钥

Gitee 提供了基于 SSH 协议的 Git 服务,在使用 SSH 协议访问仓库仓库之前,需要先配置好账户 SSH 公钥。

首先检查本机是否存在 密钥,如果存在 id_rsa(私钥)、id_rsa.pub(公钥) 文件则说明已经创建过了,直接拷贝即可。

$ ls ~/.ssh

如果不需要这份可以删除,注意这份密钥没有在使用,移除之后就无法恢复了,之前所使用的地方也需要使用新的:

$ rm -rf ~/.ssh/id_rsa
$ rm -rf ~/.ssh/id_rsa.pub

生成 SSH 公钥

Windows 用户建议使用 Windows PowerShell 或者 Git Bash,在 命令提示符 下无 cat 和 ls 命令。

1、通过命令 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 passphra

猜你喜欢

转载自blog.csdn.net/Quentin0823/article/details/133787358