GitHub SSH 密钥设置位置(网页端)
一、进入入口(按顺序点)
-
登录 GitHub 网页 → 点右上角头像
-
下拉菜单选 Settings(设置)
-
左侧菜单往下滑,找到 Access 分组 → 点 SSH and GPG keys
-
直达链接(登录后直接打开):
https://github.com/settings/keys
二、添加公钥步骤
- 点绿色按钮 New SSH key
- 填写:
- Title :随便起个名字,如
MINGW64-PC/我的笔记本 - Key type :保持默认
Authentication Key - Key :粘贴本机公钥内容(
id_ed25519.pub整行)
- Title :随便起个名字,如
- 点 Add SSH key 保存。
三、本机先准备公钥(Git Bash 执行)
bash
# 生成(邮箱填你 GitHub 注册邮箱)
ssh-keygen -t ed25519 -C "you@example.com"
# 查看公钥,复制整段输出
cat ~/.ssh/id_ed25519.pub
四、添加后测试连通性
ssh -T git@github.com
首次连接问 yes/no,输入 yes;成功提示:
Hi cxhust! You've successfully authenticated...
五、把仓库远程改成 SSH
# 查看当前地址
git remote -v
# 改成 SSH(注意是冒号,不是斜杠)
git remote set-url origin git@github.com:cxhust/51_rada.git
# 推送
git push -u origin main
