SSH 公钥设置

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

生成 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 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]-----+
  • 中间通过三次回车键确定
  1. 查看生成的 SSH 公钥和私钥:

    ls ~/.ssh/

输出:

复制代码
id_ed25519  id_ed25519.pub
  • 私钥文件 id_ed25519
  • 公钥文件 id_ed25519.pub
  1. 读取公钥文件 ~/.ssh/id_ed25519.pub:

    cat ~/.ssh/id_ed25519.pub

输出,如:

复制代码
ssh-ed25519 AAAA***5B Gitee SSH Key

复制终端输出的公钥。

相关推荐
Winlifes5 天前
我给 Codex 做了一个 Git 面板:分支树、提交历史和工作区操作
git
7177775 天前
研发平台选哪家比较好:2026年主流平台对比与Gitee选型指南
人工智能·gitee
Julien20045 天前
Docker 容器存储原理(一)
linux·运维·服务器·ssh·学习方法
Polevne5 天前
C# SFTP客户端实现文件传输
c#·ssh
ai大模型-探索者5 天前
Git在PyCharm中的使用完全指南
pycharm·gitee
明天…ling5 天前
gitee与vscode远程连接
vscode·gitee
郑州光合科技余经理6 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
我命由我123456 天前
Git 推送报错:error: src refspec main does not match any
运维·git·gitee·github·运维开发·学习方法·版本控制
Lcr3s6 天前
Git基础之(0):如何在Ubuntu(Linux)上安装git
git
Julien20046 天前
Docker 容器技术的本质
运维·服务器·ssh·学习方法