首页 > 解决方案 > 致命:协议错误:错误的行长度字符:Pa

问题描述

我最近一直在PyCharm中使用 Git 。
但是当我测试 Git URL 时,它给了我这个错误:

fatal: protocol error: bad line length character: Pa

通过专用帐户访问内部服务器上的远程存储库:

anAccount@ourServer:ourRepo

标签: pythongit

解决方案


首先检查切换协议是否有帮助:

  • 如果 Git URL 是https://github.com/...,则切换到ssh://git@github.com/...
  • 如果 Git URL 是git@github.com:...,则切换到https://github.com/...

对于 SSH URL,至少尝试:

  • 生成用于测试的PEM ssh 密钥,无需密码
  • 在其中注册公钥yourUser@yourRemoteServer:~/.ssh/authorized_keys(确保将公钥内容复制id_rsa.pub为该文件中的一行authorized_keys
  • 确保使用 OpenSSH,而不是Plink.exe

那是:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\cmd;%GH%\mingw64\bin;%PATH%

ssh-keygen -m PEM -t rsa -P "" 
# Copy the %USERPROFILE%\.ssh\id_rsa.pub content to the remote server

推荐阅读