• Ubuntu 18.04 配置 github ssh 连接


    Ubuntu 18.04 配置 github ssh 连接


    测试时间:2022年9月8日

    测试系统:Ubuntu 18.04



    1 本地检查

    在生成 SSH 密钥之前,先检查本地是否存在现有的 SSH 密钥

    ls -al ~/.ssh
    
    • 1

    检查目录列表查看是否已经有 SSH 公钥。默认情况下,GitHub 的一个支持的公钥文件名是

    • id_rsa.pub
    • id_ecdsa.pub
    • id_ed25519.pub

    如果本地已经有密钥,则上传现有密钥。

    如果本地没有密钥,则生成新的 SSH 密钥。


    2 密钥生成

    生成新的 SSH 密钥并将其添加到 ssh-agent

    生成新的 SSH 密钥

    ssh-keygen -t ed25519 -C "your_email@example.com"
    
    • 1

    如果使用的系统不支持 Ed25519 算法,则使用

    $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    
    • 1

    进一步提示 “Enter a file in which to save the key(输入要保存密钥的文件)” ,键入 Enter 按键以接受默认文件位置

    进一步提示设置安全密码,此处推荐不进行设置,直接回车跳过即可完成 SSH 密钥的生成


    3 密钥添加

    为 GitHub 账户添加 SSH 密钥

    复制本地密钥

    cat ~/.ssh/id_ed25519.pub
    
    • 1

    进入 GitHub 页面,进入用户设置中的 SSH 和 GPG 密钥设置

    新建 SSH 密钥,并将拷贝的密钥粘贴进去,点击 Add SSH Key


    4 连接测试

    测试 SSH 连接

    ssh -T git@github.com
    
    • 1

    您可能会看到类似如下的警告:

    > The authenticity of host 'github.com (IP ADDRESS)' can't be established.
    > RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    > Are you sure you want to continue connecting (yes/no)?
    
    • 1
    • 2
    • 3

    证所看到消息中的指纹是否与 GitHub 的公钥指纹匹配。 如果是,则键入 yes

    > Hi username! You've successfully authenticated, but GitHub does not
    > provide shell access.
    
    • 1
    • 2
  • 相关阅读:
    [学习笔记]Node2Vec图神经网络论文精读
    如何高效获取电商数据
    svn的常规使用
    web3.0链游农民世界开发搭建0撸狼人杀玩法模式定制开发
    Java.lang.Character类中isUpperCase()方法具有什么功能呢?
    9.4-学习ing
    Curriculum Vitae;CV
    2023年9月青少年软件编程(C 语言) 等级考试试卷(二级)
    AVL树的学习
    2022-06-28管理心得
  • 原文地址:https://blog.csdn.net/Hacker_MAI/article/details/126775509