• 【GitLab】-HTTP 500 curl 22 The requested URL returned error: 500~SSH解决


    写在前面

      本文主要介绍通过SSH的方式拉取GitLab代码。
    在这里插入图片描述



    一、场景描述

      之前笔者是通过 HTTP + Personal access token 的方式拉取、更新、提交代码的。直到有一天,休了个假。回来之后,发现代码无法拉取,其他同事也遇到同样问题。
    报如下错误:

    $ git pull
    error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500
    fatal: the remote end hung up unexpectedly
    
    • 1
    • 2
    • 3

    查询资料,未果。
    不知道是不是GitLab服务器端有人做了什么sao操作,还是其他什么原因。网上查询了一些资料,有说是缓存问题,经亲测,也没什么卵用。

    // 配置缓存的方式
    git config --global http.postBuffer 157286400
    https://stackoverflow.com/questions/44780221/git-push-failing-http-500-curl-22-the-requested-url-returned-error-500-internal
    
    • 1
    • 2
    • 3

    后来,经测试,发现通过SSH的方式可以正常拉取代码。如有人发现HTTP 500 具体错误原因的,请评论区指出,感谢~


    二、具体步骤

    1.环境说明

    名称说明
    Windows版本Win10/X64
    IntelliJ IDEA2019.2

    2.生成秘钥

    进入用户当前目录, 注意.ssh是隐藏目录

    admin@LAPTOP-ROP3B248 MINGW64 ~
    $ cd ~/.ssh
    
    • 1
    • 2

    输入命令,user@email.com 换成自己邮箱即可,其他的直接默认回车即可。

    admin@LAPTOP-ROP3B248 MINGW64 ~/.ssh
    $ ssh-keygen -t rsa -b 4096 -C "user@email.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/admin/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/admin/.ssh/id_rsa
    Your public key has been saved in /c/Users/admin/.ssh/id_rsa.pub
    The key fingerprint is:
    SHA256:5P4vWucgzRdv9adk2VJmp+Bt/7S2Q9AMU4KEzmHrBN0 user@email.com
    The key's randomart image is:
    +---[RSA 4096]----+
    |        . +..... |
    |       . = E o.  |
    |        * o   =  |
    |       o =   . o |
    |        S   o . *|
    |       . + . = Xo|
    |        o = + % =|
    |         +.= = Bo|
    |        ...oo oo*|
    +----[SHA256]-----+
    
    // 会生成2个文件
    admin@LAPTOP-ROP3B248 MINGW64 ~/.ssh
    $ ll
    total 8
    -rw-r--r-- 1 admin 197121 3389 Nov 13 11:08 id_rsa
    -rw-r--r-- 1 admin 197121  747 Nov 13 11:08 id_rsa.pub
    
    • 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

    3.GitLab添加秘钥

    登录GitLab,头像那个位置,点击settings。选择左侧SSH Keys
    在这里插入图片描述

    复制生成的文件 id_rsa.pub(公钥) 文件的内容,粘贴到key中,点击Add key
    在这里插入图片描述
    此时,邮箱会收到邮件。

    4.验证SSH方式

    将 {git地址} 替换为自己的git地址即可

    admin@LAPTOP-ROP3B248 MINGW64 ~/.ssh
    $ ssh -T git@{git地址}
    The authenticity of host '{git地址}' can't be established.
    ED25519 key fingerprint is SHA256:gyiXoXNV3lz8RqbCXnmVBBPW7WxuBVoOxnNbq8TSsUo.
    This key is not known by any other names
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '{git地址}' (ED25519) to the list of known hosts.
    Welcome to GitLab, User!
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    4.更改原有HTTP方式为SSH

    更改拉取代码的方式,以IDEA为例,选中项目,右键,Git-》Repository-》Remotes
    修改URL由HTTP修改为SSH方式。说明:IDEA版本不同,步骤会有所不同

    原有:	http://{git地址}/ace-group/ace-conf-parent.git
    修改为:	git@{git地址}:ace-group/ace-conf-parent.git
    
    • 1
    • 2

    在这里插入图片描述

    至此,就又可以愉快地玩耍了~


    三、参考资料

    gitlab 配置ssh key,通用ssh拉取代码


    写在后面

      如果本文内容对您有价值或者有启发的话,欢迎点赞、关注、评论和转发。您的反馈和陪伴将促进我们共同进步和成长。


    系列文章

    【GitLab】-HTTP Basic: Access denied.remote:You must use a personal access token
    【GitLab】-批量克隆更新GibLab项目脚本(Python版本)

  • 相关阅读:
    uniapp插件自定义
    2023秋冬系列丨追求本真的自然纯粹之美
    SS-Model【2】:DeepLabv1
    Python 奇淫技巧,助你更好的摸鱼
    MindSpore处理自定义数据集的时候报错
    【动画笔记】数据结构-AVL树的插入操作
    MySQL开窗函数
    【Spring Boot】Spring Boot中的简单查询
    express学习36-多人管理28用户信息展示
    天翎知识管理系统:强大的权限管理功能,保障知识安全
  • 原文地址:https://blog.csdn.net/u010773514/article/details/134406445