【Gitlab】【Git】git push 時,回應 fatal: protocol error: bad line length character: xxx

發生這種事情的原因很多
訊息也沒有什麼幫助
總之情況是這樣的

狀況

利用 gitlab 的 webhook event 去觸發自己寫的 python service
python 再去觸發專案做 SSH 的 git push 動作
回應
# git push git@myip:myproject
fatal: protocol error: bad line length character:s

解決方案

在這次問題中,重要的是檢查你的ssh key
gitlab不信任git這個user
以下連結可能會有幫助,但是不適用在這個問題
Strange error in gitlab: fatal: protocol error: bad line length character: Depl
Git push results in fatal: protocol error: bad line length character: This
GitLab fails to start: "This account is currently not available."
/sbin/login seems to not work for pull/push

解決步驟

產生你的sshkey
# ssh-keygen
# cd ~/.ssh
找出剛剛產生的.pub,複製裡面的內容
# cat id_rsa.pub
貼到gitlab上profile setting裡面的ssh keys


關鍵字用錯,就會浪費你非常多的人生

留言