无法在Windows上克隆,但可以从Gitlab服务器在Linux上克隆
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了无法在Windows上克隆,但可以从Gitlab服务器在Linux上克隆,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5673字,纯文字阅读大概需要9分钟。
内容图文
![无法在Windows上克隆,但可以从Gitlab服务器在Linux上克隆](/upload/InfoBanner/zyjiaocheng/950/32a36d1ec1fc490aa0eb3c6bf7ca26b0.jpg)
我试图通过SSH从远程Gitlab服务器克隆存储库.我使用Gitlab CE版本9.3.9 755bb71和TortoiseGIT版本2.5.0和git(用于Windows)版本2.14.0
SSH密钥已正确安装,因为我已使用测试身份验证
ssh -vT git@192.168.100.100 -i /path/to/.ssh/key
我使用上面的密钥获得以下消息验证成功
OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.100.100 [192.168.100.100] port 22.
debug1: Connection established.
debug1: identity file /path/to/.ssh/key type 1
debug1: key_load_public: No such file or directory
debug1: identity file /path/to/.ssh/key-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 192.168.100.100:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:fEztD+bNxKRs24poXJMlP0GBAP6Q1dZT80OhQAtDQJE
debug1: Host '192.168.100.100' is known and matches the ECDSA host key.
debug1: Found key in /path/to/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /path/to/.ssh/key
debug1: Server accepts key: pkalg ssh-rsa blen 535
Enter passphrase for key '/path/to/.ssh/key':
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.100.100 ([192.168.100.100]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
Welcome to GitLab, John Doe!
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3476, received 3264 bytes, in 2.2 seconds
Bytes per second: sent 1574.0, received 1478.0
debug1: Exit status 0
当我在Windows上使用TortoiseGit克隆存储库时,我在客户端上收到以下错误
Cloning into 'C:\path\folder'...
GitLab: Disallowed command
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
在gitlab服务器上,在gitlab-shell.log中,我收到以下警告消息
WARN -- : gitlab-shell: Attempt to execute disallowed command <git upload-pack '/path/to/repo.git'> by user with key key-1.
但是当我从另一个使用不同SSH密钥的linux机器上尝试git clone时,它是成功的,我在gitlab-shell.logon gitlab服务器上得到以下信息消息
INFO -- : gitlab-shell: executing git command <gitaly-upload-pack {"repository":{"path":"/very/long/path/to/repo.git"},"gl_id":"key-2"}> for user with key key-2.
我花了超过10个小时试图调试一切,我不确定有什么区别或问题究竟在哪里.我也尝试在TortoiseGit的本地.gitconfig文件中添加以下内容,但这不会改变任何内容.
[remote "origin"]
uploadpack = git-upload-pack
最后,通过HTTPS克隆相同的存储库工作正常,使用用户名/密码没有任何问题.
解决方法:
注意:我刚刚升级到适用于Windows的Git 2.14.0 ……并且没有一个ssh url正在运行:
> git ls-remote
GitLab: Disallowed command
fatal: Could not read from remote repository.
(原点是ssh url)
另一个副作用:git-for-windows/git issue 1258
fatal: protocol error: bad line length character: Not
It looks as if BitBucket looks at
argv[0]
(typicallygit-upload-pack
, with the regression git) to determine whether it is a permitted command.So I think it is by design that
git
is rejected whilegit-upload-pack
is not.
同样在GitLab上出错:gitlab-ce issue 36028.
pending merge request在检测到git xxx命令时显式恢复git-xxx.
见gitlab_shell.rb#parse_cmd(args)
def parse_cmd(args)
# Handle Git for Windows 2.14 using "git upload-pack" instead of git-upload-pack
if args.length == 3 && args.first == 'git'
@command = "git-#{args[1]}"
args = [@command, args.last]
else
@command = args.first
end
在Git for Windows端,正在进行修复:see commit 0f33428
Revert “git_connect: prefer Git’s builtins over dashed form”
It would appear that this change (which was intended to fix tests
interacting with local repositories whengit-upload-pack
was not in the
PATH
) regresses on SSH access.
A Git for Windows 2.14.0(2)正在进行中,并且在此编辑时30分钟前刚刚发布(2017-08-07T11:05:34Z UTC).
原始答案
如果key1与/path/to/.ssh/key相同并且确定了John Doe,那么这应该意味着John Doe无法访问该repo(as in here).
检查key2是否与其他用户关联.
如果两个密钥都引用同一个用户,则更多的是本地配置问题(如this answer所示).
还要检查您的TortoiseGit是否使用与测试中相同的密钥:
set "GIT_COMMAND_SSH=ssh -v"
# launch TortoiseGit from that CMD session
然后,您将看到TortoiseGit在使用ssh url克隆repo时正在使用的内容.您可能需要define an .ssh/config file.
内容总结
以上是互联网集市为您收集整理的无法在Windows上克隆,但可以从Gitlab服务器在Linux上克隆全部内容,希望文章能够帮你解决无法在Windows上克隆,但可以从Gitlab服务器在Linux上克隆所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。