• 创建公私钥对连接远程仓库


    创建公私钥对连接远程仓库

    参考

    https://gitee.com/help/articles/4181#article-header0
    

    步骤

    ssh-keygen -t rsa -C "1215135027@qq.com" 在本地生成 rsa 公私钥。直接回车。名称必须是默认的id_rsa

    将公钥保存到码云

    ssh -T git@gitee.com 测试连接生成 known_hosts 文件,测试连接的时候要输入 yes 不能直接回车

    ssh-keygen生成公私钥

    1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01
    $ ssh-keygen -t rsa -C "1215135027@qq.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/1/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/1/.ssh/id_rsa.
    Your public key has been saved in /c/Users/1/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:3n4Ctfa9e59mAKmFxxY+4z+3i7Y73vrB46iAO9wL5q0 1215135027@qq.com
    The key's randomart image is:
    +---[RSA 3072]----+
    |                 |
    |           .     |
    |          + o    |
    |         ..@     |
    |        S.*.+    |
    |       .ooo. ..  |
    |      .+o+.....+ |
    |      oo+oo o=*+=|
    |       Eooo++B&@=|
    +----[SHA256]-----+
    

    码云配置公钥

    设置 > 安全设置 > SSH公钥

    测试连接生成know_hosts文件

    1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01
    $ ssh -T git@gitee.com
    The authenticity of host 'gitee.com (212.64.62.174)' can't be established.
    ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added 'gitee.com,212.64.62.174' (ECDSA) to the list of known hosts.
    Hi 魔有追求! You've successfully authenticated, but GITEE.COM does not provide shell access.
    

    注意

    私钥名称必须为默认的id_rsa,并且放在用户目录的.ssh文件夹下。

    C:Users1.ssh>tree /f
    卷 Windows 的文件夹 PATH 列表
    卷序列号为 AE9A-3125
    C:.
    │  id_rsa
    │  id_rsa.pub
    │  known_hosts
    

    同时连接多个库,这些库默认都是读取id_rsa文件,可以建立文件夹,用哪个库把哪个库的rsa文件粘贴出来。比如我要用学成的公私钥,我就把他粘贴出来放到 .ssh文件夹中。

    C:Users1.ssh>tree /f
    卷 Windows 的文件夹 PATH 列表
    卷序列号为 AE9A-3125
    C:.
    │  id_rsa
    │  id_rsa.pub
    │  known_hosts
    │
    ├─sand
    │      id_rsa
    │      id_rsa.pub
    │      known_hosts
    │
    ├─store_sand
    │      id_rsa
    │      id_rsa.pub
    │      known_hosts
    │
    └─xc
            id_rsa
            id_rsa.pub
            known_hosts
    

    bugs

    # 生成的私钥名称必须为id_rsa,也就是默认的名称,不然的话也会找不到。
    C:Users1.ssh>tree /f
    卷 Windows 的文件夹 PATH 列表
    卷序列号为 AE9A-3125
    C:.
    │  id_rsa
    │  id_rsa.pub
    │  known_hosts
    
    # 连接测试时如果直接回车,不输入yes,则会显示被拒绝。输入yes则会连接成功。
    1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01
    $ ssh -T git@gitee.com
    The authenticity of host 'gitee.com (212.64.62.174)' can't be established.
    ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    Host key verification failed.
    
    # 连接测试时如果直接回车,输入yes连接成功。
    1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01
    $ ssh -T git@gitee.com
    The authenticity of host 'gitee.com (212.64.62.174)' can't be established.
    ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added 'gitee.com,212.64.62.174' (ECDSA) to the list of known hosts.
    Hi 魔有追求! You've successfully authenticated, but GITEE.COM does not provide shell access.
    
  • 相关阅读:
    大前端的自动化工厂(1)——Yeoman
    推荐两个漂亮的编程字体
    javascript基础修炼(3)—What's this(下)
    javascript基础修炼(2)——What's this(上)
    javascript基础修炼(1)——一道十面埋伏的原型链面试题
    2018年8月中级前端开发推荐书籍
    React组件方法中为什么要绑定this
    Angularjs进阶笔记(2)-自定义指令中的数据绑定
    Angularjs1.X进阶笔记(1)—两种不同的双向数据绑定
    mysql多表查询
  • 原文地址:https://www.cnblogs.com/mozq/p/11824468.html
Copyright © 2020-2023  润新知