git 公钥问题

  1. Unbantu系统

  2. git 生成ssh密钥(先检查是否已经有)
    在这里插入图片描述

  3. 如果没有id_dsa.pub,则需要生成(邮箱名为授权拉取代码的邮箱)

     ssh-keygen -t rsa -C 'xx@xx.com'
    
  4. 查看ssh密钥并全部复制

      cat ~/.ssh/id_rsa.pub
    
  5. 一般情况这样就可以了,但是如果报错为:

     The authenticity of host '[git.mioffice.cn]:29418 ([10.142.196.21]:29418)' can't be established.
     	RSA key fingerprint is SHA256:iLyah8Dxi5hhuy/LC0DAwatACBwYR5ptFj07MWaI1w8.
     	Are you sure you want to continue connecting (yes/no)? yes
     	Warning: Permanently added '[git.mioffice.cn]:29418,[10.142.196.21]:29418' (RSA) to the list of known hosts.
     	sign_and_send_pubkey: signing failed: agent refused operation
     Permission denied (publickey).
     fatal: Could not read from remote repository.
     
     Please make sure you have the correct access rights
     and the repository exists.、
    
  6. 先去工程目录下找到隐藏 .git文件夹(ubuntu下 ctrl+h) ,然后打开,找到config文件并编辑

     url = xxx...gerrit.pt.mioffice.cn:...xxxx
    
  7. 则需要添加sshkey至ssh-agent

     (1)执行eval “$(ssh-agent -s)”确认ssh-agent处于开启状态,打印pid... 表示启用中;
     (2)执行指令ssh-add ~/.ssh/id_rsa 添加ssh key至ssh agent
    
  8. 最后执行clone命令即可

  9. windows

1.生成
ssh-keygen -t ed25519 -C "email@example.com"
2.复制
 cat ~/.ssh/id_ed25519.pub | clip
3.添加到 gitlab 等
3.验证
ssh -T git@gitlab.com  (gitlab.com替换为自己的 例如gitlab.ziroom.com)
  1. 查看失败原因
ssh -vvv git@gitlab.com
  1. 升级mac版本带来的git问题
主要提示失败信息为:send_pubkey_test: no mutual signature algorithm
debug1: Server host key: ssh-ed25519 

原因:OpenSSH 版本太高

解决方案:更换秘钥生成算法,使用 ed25519 算法生成
ssh-keygen -t ed25519 -C "your email"

最后注意 cat id_ed25519.pub  而不是 id_rsa.pub
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值