首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GIT: fatal:协议错误:错误的行长度字符: This

GIT: fatal:协议错误:错误的行长度字符: This
EN

Stack Overflow用户
提问于 2020-11-19 02:14:12
回答 1查看 171关注 0票数 1

尝试使用SSH URL进行克隆时出现以下错误:

代码语言:javascript
运行
复制
$ 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:

代码语言:javascript
运行
复制
GIT_SSH_COMMAND='ssh -v' git clone git@host:repository.git

GIT_SSH_COMMAND='ssh -v' git clone git@host:repository.git

上述命令的输出片段

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

发布于 2020-11-19 02:14:12

检查什么是受支持的shell

代码语言:javascript
运行
复制
cat /etc/shells

在我们的示例中,git用户禁用了shell,下图显示了/sbin/nologin

已停止gitlab实例

代码语言:javascript
运行
复制
gitlab-ctl stop

为git用户更新shell (您可以使用以下任何命令)

代码语言:javascript
运行
复制
usermod -s which git-shell git
usermod -s /bin/sh git

重新配置GitLab

代码语言:javascript
运行
复制
gitlab-ctl reconfigured

重新启动GitLab服务

代码语言:javascript
运行
复制
gitlab-ctl restart

最后,验证git用户的/sbin/nologin是否已更改为/bin/sh,如下图所示

代码语言:javascript
运行
复制
vi /etc/passwd | grep git

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64898925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档