刚学 老是忘 网上的教程一堆废话 我看不懂 自己记录一下 linux里复制下面代码生成了密钥添加到github里就行了

使用 SSH 密钥

  1. 生成 SSH 密钥(如果你还没有):

    ssh-keygen -t rsa -b 4096 -C "[email protected]"

    [email protected] 更改为你的自己的邮箱

  2. 添加 SSH 密钥到 SSH 代理

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
  3. 将 SSH 公钥添加到 GitHub

    • 复制公钥到剪贴板:
    cat ~/.ssh/id_rsa.pub
    • 登录到 GitHub,进入 Settings > SSH and GPG keys > New SSH key,粘贴公钥并保存。
  4. 使用 SSH URL 进行推送

    • 修改远程仓库的 URL 为 SSH 格式:
    git remote set-url origin [email protected]:lianlianlianlianlianlian/2DxRandom.git

    ps:ssh url推送就是git@开头的那个地址 https推送要输入账号密码 不方便

    然后再尝试推送:

    git push -u origin main
最后修改:2024 年 10 月 18 日
如果觉得我的文章对你有用,请随意赞赏