下面是把新 SSH 公钥添加到 GitLab 的标准流程(适用于 GitLab.com 和自建 GitLab):
- 复制你的公钥到剪贴板
Windows(Git Bash 示例,官方文档给的方式):
cat ~/.ssh/id_ed25519.pub | clip
如果你用的是 PowerShell,也可以:
Get-Content $env:USERPROFILE.ssh/id_ed25519.pub | clip
(docs.gitlab.com)
- 在 GitLab Web 页面添加
- 右上角头像 → Edit profile(或 Preferences)
- 左侧选择 SSH Keys
- 点击 Add new key
- Key 粘贴你的公钥(以
ssh-ed25519开头) - 填 Title(如 “Work Laptop”)
- 可选:Usage type / Expiration date
- 点击 Add key
(docs.gitlab.com)
- 验证连接
添加后再测试 SSH 连接(你们是 2222 端口):
ssh -T -p 2222 git@192.168.123.125