zoukankan      html  css  js  c++  java
  • git命令怎么使用tortoise git已经生成的秘钥(windows)

    习惯了使用Tortoise git,突然想用一下git 原生命令,发现git pull执行失败

    Host key verification failed.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    原因是没有配置ssh秘钥,那可以共用tortoise git的秘钥吗,答案是:可以

    Step1:创建文件夹 C:Users{yourName}.ssh

    Step2: tortoise git使用的是ppk方式生成的秘钥,我们需要使用tortoise git下的puttygen工具转换秘钥

    找到ppk文件,在Conversions菜单下的 Export SSH Key
    保存私钥到.ssh目录下文件名为id_rsa
    保存公钥(save public key)到.ssh目录下名为id_rsa.pub

    Step3: 新建config文件,配置你的git源信息

    # 域名地址的别名
    Host xxx
        # 这个是真实的域名地址
        Hostname git@xxx.com
        # 配置使用用户名
        User yourUserName
        # 这里是id_rsa的目录位置
        IdentityFile ~/.ssh/id_rsa
        # 默认是22,如果是其他端口,一定要配置
        Port 2222
    

    以上就完成了ssh 秘钥重用,可以使用ssh -T git@xxx.com命令验证

    当然你有多个git源或者已经有了id_rsa时,可以将对应的名字修改为其他名称即可,修改包括三处:两个文件名(公钥和私钥)以及config里的IdentityFile 名称

  • 相关阅读:
    2020年MongoDB 企业应用实战 基础 复制集 分片集群
    2020年Redis5.0 从入门到企业应用实战
    2020年Jumpserver1.5.8企业生产部署指南
    python单例与数据库连接池
    python 异常处理
    python 正则
    python 多线程
    python 队列
    python 闭包与装饰器
    程序员面试资源集锦
  • 原文地址:https://www.cnblogs.com/tom-chang/p/14952133.html
Copyright © 2011-2022 走看看