SSH 公钥设置

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

生成 SSH 公钥

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

  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

复制终端输出的公钥。

相关推荐
AIMath~3 分钟前
Git 子模块(Submodule)目录结构清除实战复盘
git
切糕师学AI40 分钟前
Ubuntu 下 Git 完全使用指南
linux·git·ubuntu
一袋米扛几楼982 小时前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
尘埃落定wf3 小时前
# GitHub CLI:告别繁琐的 Git 命令,让开发更高效
git·github
恋喵大鲤鱼3 小时前
git clone
git·git clone
金牛IT5 小时前
Gogs 轻量级 Git 服务器搭建与使用
运维·服务器·git
魔极客7 小时前
第十二节:龙晰 AnolisOS-23.4-x86_64.qcow2 虚拟机的网络配置方式及 ssh 连接
网络·ssh·php
Qres82116 小时前
Git安装记录
git
wj30558537817 小时前
Codex + Git 开发环境配置指南(WSL版)
linux·运维·git
楠枬20 小时前
Git 分支管理
git