为什么要用 SSH 连接 GitHub?
– 🔒 更安全:避免账号密码泄露风险
– ⚡ 更快速:无需每次输入凭据
– 🤖 更适合自动化:方便 CI/CD 流程使用
- 生成 SSH 密钥对
ssh-keygen -t rsa -b 4096 -C "你的邮箱"
回车三次
- 添加公钥到 GitHub
cat ~/.ssh/id_rsa.pub
复制公钥内容
登录 GitHub → Settings → SSH and GPG Keys → New SSH Key
粘贴公钥并保存
- 验证
ssh -T [email protected]
看到欢迎信息即表示成功!
在克隆仓库使用ssh链接即可