首先,我使用以下命令创建了 ssh 密钥对:
ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
Run Code Online (Sandbox Code Playgroud)
然后,我将 id_rsa.pub 文件的内容添加到我的 GitLab 配置文件中。但是当我尝试测试我的 SSH 密钥是否已正确添加时:
ssh -vvvT user@some.gitlab.com
Run Code Online (Sandbox Code Playgroud)
输入正确的密码后,我得到以下日志:
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
Run Code Online (Sandbox Code Playgroud)
没有别的。日志打印已停止,控制台现已冻结。我还尝试使用命令从我的 GitLab 克隆一些项目:
git clone ssh://user@some-gitlab-url/some-project.git
Run Code Online (Sandbox Code Playgroud)
但我有错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?
shell request accepted on channel 0
Run Code Online (Sandbox Code Playgroud)
这意味着 ssh 部分可能正在工作。
用于克隆存储库的 URL 将不起作用:
所以不是 ssh://user@some-gitlab-url/some-project.git 而是
ssh://git@some-gitlab-url/some-group/some-project.git
Run Code Online (Sandbox Code Playgroud)
正如OP在聊天中发现的那样,问题出在所使用的SSH库上。
问题出在 OpenSSH 客户端上。
在讨论过程中,我使用的是 Windows 版 OpenSSH 客户端。
更改为 Git Bash 后,它就开始工作了!
我在这里提到Windows 10 (1809+) 添加了OpenSSH 客户端(和服务器)。
但是Windows 版 Git附带了OpenSSH 8.1。
由于 Windows SSH 是PowerShell/openssh-portableopenSSH 的一个分支 ( ),因此使用 Git 中的 SSH 更安全。
更一般地说,使用 Git 并使用以下开头的路径:
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\cmd;%GH%\mingw64\bin;%PATH%
Run Code Online (Sandbox Code Playgroud)
这将确保您首先使用 Git 及其运行时依赖项(然后是 Windows)。
| 归档时间: |
|
| 查看次数: |
9724 次 |
| 最近记录: |