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 名称

  • 相关阅读:
    Python3 sorted() 函数
    [Python网络编程]一个简单的TCP时间服务器
    [爬虫]统计豆瓣读书中每个标签下的前两百本书
    [leetcode]39. Combination Sum
    [leetcode]18. 4Sum
    [leetcode DP]72. Edit Distance
    [leetcode DP]120. Triangle
    [leetcode DP]91. Decode Ways
    [leetcode DP]70. Climbing Stairs
    [leetcode DP]64. Minimum Path Sum
  • 原文地址:https://www.cnblogs.com/tom-chang/p/14952133.html
Copyright © 2011-2022 走看看