尝试使用SSH URL进行克隆时出现以下错误:
$ git clone git@host:repository.git
Cloning into 'test'...
fatal: protocol error: bad line length character: This
我们在本地使用GitLab,并使用SSH URL来克隆存储库。昨天,所有用户和Jenkins都报告了克隆、拉取和推送代码到存储库的问题。我们很快发现HTTPS协议按预期工作,这个问题被缩小到每个使用SSH URL的人。
以下是我们试图获得更多详细信息但没有帮助的一些事情,除了我们看到身份验证后失败,退出状态随机为254或1:
GIT_SSH_COMMAND='ssh -v' git clone git@host:repository.git
GIT_SSH_COMMAND='ssh -v' git clone git@host:repository.git
上述命令的输出片段
debug1: Authentication succeeded (publickey).
Authenticated to host ([a.y.x.b]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
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.
debug1: Sending environment.
debug1: Sending env GIT_PROTOCOL = version=2
debug1: Sending command: git-upload-pack 'repository.git'
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
fatal: protocol error: bad line length character: This
Transferred: sent 2352, received 2984 bytes, in 0.1 seconds
Bytes per second: sent 22560.7, received 28622.9
debug1: Exit status 1
发布于 2020-11-19 02:14:12
检查什么是受支持的shell
cat /etc/shells
在我们的示例中,git用户禁用了shell,下图显示了/sbin/nologin
已停止gitlab实例
gitlab-ctl stop
为git用户更新shell (您可以使用以下任何命令)
usermod -s which git-shell git
usermod -s /bin/sh git
重新配置GitLab
gitlab-ctl reconfigured
重新启动GitLab服务
gitlab-ctl restart
最后,验证git用户的/sbin/nologin是否已更改为/bin/sh,如下图所示
vi /etc/passwd | grep git
https://stackoverflow.com/questions/64898925
复制相似问题