• Ubuntu 配置 Github 的 SSH keys


    先进入已有的 Git 目录或使用新建的一个 Git 仓库下。

    设置 Github 用户名和邮箱:

    $ git config --global user.name [Github用户名]
    $ git config --global user.email [Github认证邮箱]
    
    • 1
    • 2

    生成 SSH 密钥文件:

    $ ssh-keygen -t rsa -C [Github认证邮箱]
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
    [按 Enter 键接受默认文件位置]
    Enter passphrase (empty for no passphrase): 
    [按 Enter 不设置安全口令, 如果设置, 每次使用 Git 命令时都需要输入]
    Enter same passphrase again:
    [重复安全口令, 如果上一步没有设置, 按 Enter 跳过]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    ~/.ssh/ 目录下会创建两个文件:

    • id_rsa: 私钥文件
    • id_rsa.pub: 公钥文件

    公钥文件内容打印后复制:

    $ cat ~/.ssh/id_rsa.pub
    
    • 1

    登陆 Github 点击 右上角头像 -> Settings -> SSH and GPG keys -> New SSH key 输入以下内容:

    • Title: 任意取名
    • Key type: Authentication Key
    • Key: 复制上一步中的公钥文件内容到此处

    点击 Add SSH key 完成创建, 验证 Authentication 是否正常:

    $ ssh -T git@github.com
    The authenticity of host 'github.com (0.0.0.0)' can't be established.
    ED25519 key fingerprint is SHA256:+xxxxxxxxx/xxxxxxxxx.
    This key is not known by any other names
    Are you sure you want to continue connecting (yes/no/[fingerprint])? 
    [选择 yes 使服务器的连接信息保存在系统中]
    Warning: Permanently added 'github.com' (ED0000) to the list of known hosts.
    Hi [Github用户名]! You've successfully authenticated, but GitHub does not provide shell access.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    最后输出 Hi [Github用户名]! You've successfully authenticated, but GitHub does not provide shell access. 就表示配置成功了。

  • 相关阅读:
    【第五部分 | JS WebAPI】3:DOM 节点操作
    zabbix监控平台部署(二)
    Dom.nodeType
    云计算与大数据第16章 分布式内存计算平台Spark习题
    Spring值IOC
    Ubuntu22.04本地部署PaddleSpeech实验代码(GPU版)
    Python3操作redis百万级数据迁移,单机到单机,集群到集群
    【Nacos】源码之服务端服务注册
    前端开发工程师工作梳理
    关于HTTP模块访问之后响应网页
  • 原文地址:https://blog.csdn.net/hekaiyou/article/details/134352213