• linux 安装配置github


    1. 安装git

    yum install git
    
    • 1
    Last metadata expiration check: 0:08:02 ago on Wed 29 Jun 2022 02:43:07 PM CST.
    Dependencies resolved.
    ======================================================================================================================== Package                         Architecture          Version                           Repository                Size
    ========================================================================================================================Installing:
     git                             x86_64                2.27.0-1.el8                      AppStream                164 k
    Installing dependencies:
     git-core                        x86_64                2.27.0-1.el8                      AppStream                5.7 M
     git-core-doc                    noarch                2.27.0-1.el8                      AppStream                2.5 M
     perl-Error                      noarch                1:0.17025-2.el8                   AppStream                 46 k
     perl-Git                        noarch                2.27.0-1.el8                      AppStream                 77 k
     perl-TermReadKey                x86_64                2.37-7.el8                        AppStream                 40 k
    
    Transaction Summary
    ========================================================================================================================Install  6 Packages
    
    Total download size: 8.5 M
    Installed size: 45 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/6): git-2.27.0-1.el8.x86_64.rpm                                                      335 kB/s | 164 kB     00:00
    (2/6): perl-Error-0.17025-2.el8.noarch.rpm                                              291 kB/s |  46 kB     00:00
    (3/6): perl-Git-2.27.0-1.el8.noarch.rpm                                                  42 kB/s |  77 kB     00:01
    (4/6): perl-TermReadKey-2.37-7.el8.x86_64.rpm                                           274 kB/s |  40 kB     00:00
    (5/6): git-core-doc-2.27.0-1.el8.noarch.rpm                                             430 kB/s | 2.5 MB     00:05
    (6/6): git-core-2.27.0-1.el8.x86_64.rpm                                                 429 kB/s | 5.7 MB     00:13
    ------------------------------------------------------------------------------------------------------------------------Total                                                                                   644 kB/s | 8.5 MB     00:13
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                                1/1
      Installing       : git-core-2.27.0-1.el8.x86_64                                                                   1/6
      Installing       : git-core-doc-2.27.0-1.el8.noarch                                                               2/6
      Installing       : perl-TermReadKey-2.37-7.el8.x86_64                                                             3/6
      Installing       : perl-Error-1:0.17025-2.el8.noarch                                                              4/6
      Installing       : perl-Git-2.27.0-1.el8.noarch                                                                   5/6
      Installing       : git-2.27.0-1.el8.x86_64                                                                        6/6
      Running scriptlet: git-2.27.0-1.el8.x86_64                                                                        6/6
      Verifying        : git-2.27.0-1.el8.x86_64                                                                        1/6
      Verifying        : git-core-2.27.0-1.el8.x86_64                                                                   2/6
      Verifying        : git-core-doc-2.27.0-1.el8.noarch                                                               3/6
      Verifying        : perl-Error-1:0.17025-2.el8.noarch                                                              4/6
      Verifying        : perl-Git-2.27.0-1.el8.noarch                                                                   5/6
      Verifying        : perl-TermReadKey-2.37-7.el8.x86_64                                                             6/6
    
    Installed:
      git-2.27.0-1.el8.x86_64                  git-core-2.27.0-1.el8.x86_64        git-core-doc-2.27.0-1.el8.noarch
      perl-Error-1:0.17025-2.el8.noarch        perl-Git-2.27.0-1.el8.noarch        perl-TermReadKey-2.37-7.el8.x86_64
    
    Complete!
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    2. 配置用户名和邮箱

    git config --global user.name "username"
    git config --global user.email "your_email@example.com"
    
    • 1
    • 2

    这里global是配置全局用户名和邮箱,去掉–global参数,可以为当前目录的仓库单独配置用户名和邮箱。

    完了可以使用下面的命令查看配置

     git config --get user.name
    
    • 1

    3. 配置SSH

    • 3.1 生成SSH密钥

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

      这将使用提供的电子邮件作为标签创建一个新的 SSH 密钥。

      ed25519是一种密码算法。

      Generating public/private rsa key pair.
      Enter file in which to save the key (/root/.ssh/id_rsa): github
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in github.
      Your public key has been saved in github.pub.
      The key fingerprint is:
      SHA256:sxxxxxxxxxxxxxxxxxxxxxxx xxx@xxx
      The key's randomart image is:
      +---[RSA 3072]----+
      |        ....o ..=|
      |         ..+ = B+|
      |      o .   = X *|
      |       +   o = * |
      |      . S +   . .|
      |     . + + o     |
      |      . + o o... |
      |         B . .o.E|
      |        +.+. o+*+|
      +----[SHA256]-----+
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20

      运行后依次需要输入密钥文件名、密钥密码和确认密码。可以直接enter,使用默认的。
      我这边是给出了文件名.

    • 3.2 将SSH密钥添加到ssh-agent

      eval "$(ssh-agent -s)"
      $ ssh-add ~/.ssh/github
      
      • 1
      • 2
      Identity added: /root/.ssh/github (xxxxx@xxx.com)
      
      • 1

      将github替换为你的密钥名。

      如果不进行这一步,直接跳到下面第三步,将不能使用ssh访问github。

      ssh -T git@github.com
      The authenticity of host 'github.com (20.205.243.166)' can't be established.
      ECDSA key fingerprint is SHA256:pxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
      Are you sure you want to continue connecting (yes/no/[fingerprint])? Y
      Please type 'yes', 'no' or the fingerprint: yes
      Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
      git@github.com: Permission denied (publickey).
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7

      访问被拒绝。

    • 3.3 复制公钥,打开 github - setting - 左侧 SSH and GPG keys - new SSH key

      测试访问

      ssh -T git@github.com
      Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
      
      • 1
      • 2

    4. 使用SSL方式克隆仓库到本地

     git clone git@github.com:user/repo.git
    
    • 1
    Cloning into 'repo'...
    remote: Enumerating objects: 55, done.
    remote: Counting objects: 100% (55/55), done.
    remote: Compressing objects: 100% (39/39), done.
    remote: Total 55 (delta 21), reused 47 (delta 13), pack-reused 0
    Receiving objects: 100% (55/55), 53.29 KiB | 230.00 KiB/s, done.
    Resolving deltas: 100% (21/21), done.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    文章参考:

    github文档 - 在 Git 中设置用户名
    github文档 - 生成新的 SSH 密钥

  • 相关阅读:
    【数据结构与算法】<==>二叉树下
    一文了解 Java 中的构造器
    代码随想录训练营 股票03
    2022谷粒商城学习笔记(二十二)rabbitMQ学习
    Internet Download Manager永久版功能强大的网络下载器
    nodejs+mysql+vscode网上图书商城销售管理系统vue
    高企申报需要的专利数量是多少?
    python导入的缓存机制
    Ubuntu查看端口开放情况
    网络——彻底搞懂数据时延的相关计算
  • 原文地址:https://blog.csdn.net/u012413551/article/details/125524039