gpt4 book ai didi

git - 无法通过 ssh 连接到 GitLab

转载 作者:行者123 更新时间:2023-12-02 14:16:56 24 4
gpt4 key购买 nike

首先,我使用以下命令创建了 ssh key 对:

ssh-keygen -o -t rsa -b 4096 -C "email@example.com"

然后,我将 id_rsa.pub 文件的内容添加到我的 GitLab 配置文件中。
但是当我尝试测试我的 SSH key 是否正确添加时:
ssh -vvvT user@some.gitlab.com

输入正确的密码后,我得到以下日志:
debug3: send packet: type 61
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 0
debug3: send packet: type 61
debug3: receive packet: type 52
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to some.gitlab.com ([xxx.xxx.xxx.xxx]:xx).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last failed login: Sun Jan 26 21:33:13 UTC 2020 from some-freeipa.com on ssh:notty

没有别的。日志打印已停止,控制台现在被卡住。
我还尝试使用以下命令从我的 GitLab 克隆一些项目:
git clone ssh://user@some-gitlab-url/some-project.git

但我有错误:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

任何人都可以请帮我解决这个问题吗?

最佳答案

shell request accepted on channel 0

这意味着 ssh 部分可能正在工作。

用于克隆 repo 的 URL 将不起作用:
  • 用户需要是 git(总是在典型的 GitLab 安装中)
  • URL 需要包含用户/组和存储库

  • 所以不是 ssh://user@some-gitlab-url/some-project.git 而是
    ssh://git@some-gitlab-url/some-group/some-project.git

    如发现 by the OP in the chat , 问题是使用的 SSH 库 .

    The problem was with OpenSSH client.
    During the discussion I was using OpenSSH client for Windows.
    After it was changed to Git Bash it has started to work!



    mentioned here Windows 10 (1809+) 添加了 OpenSSH Client (和服务器)。
    但是 Git for Windows自带 OpenSSH 8.1 .

    由于 Windows SSH 是 openSSH 的一个分支 ( PowerShell/openssh-portable ),因此使用 Git 中的一个更安全。

    更一般地,使用带有以下开头的路径的 Git:
    set GH=C:\path\to\git
    set PATH=%GH%\bin;%GH%\usr\bin;%GH%\cmd;%GH%\mingw64\bin;%PATH%

    这将确保您首先使用 Git 及其运行时依赖项(然后是 Windows)。

    关于git - 无法通过 ssh 连接到 GitLab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59923066/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com