git-lfs / git-lfs

Git extension for versioning large files
https://git-lfs.com
Other
12.97k stars 2.04k forks source link

pure SSH protocol connection failed: Unable to negotiate version with remote side (unable to read capabilities): EOF #5869

Open Zherphy opened 1 month ago

Zherphy commented 1 month ago

HI everyone, I have issue.. I want to use SSH upload a file. When trying git push, some error happened... I have tried many solutions to solve this, but it still show me EOF.

System environment git version 2.34.1 git-lfs/3.5.1 (GitHub; linux amd64; go 1.21.8)

git lfs env `Endpoint=https://{ip}//home/ssh-test-project/test-project (auth=none) SSH=(user)@(ip):/home/ssh-test-project/test-project

LocalWorkingDir=/home/ssh-test-project/test-project LocalGitDir=/home/ssh-test-project/test-project/.git LocalGitStorageDir=/home/ssh-test-project/test-project/.git LocalMediaDir=/home/ssh-test-project/test-project/.git/lfs/objects LocalReferenceDirs= TempDir=/home/ssh-test-project/test-project/.git/lfs/tmp ConcurrentTransfers=8 TusTransfers=false BasicTransfersOnly=false SkipDownloadErrors=false FetchRecentAlways=false FetchRecentRefsDays=7 FetchRecentCommitsDays=0 FetchRecentRefsIncludeRemotes=true PruneOffsetDays=3 PruneVerifyRemoteAlways=false PruneVerifyUnreachableAlways=false PruneRemoteName=origin LfsStorageDir=/home/ssh-test-project/test-project/.git/lfs AccessDownload=none AccessUpload=none DownloadTransfers=basic,lfs-standalone-file,ssh UploadTransfers=basic,lfs-standalone-file,ssh GIT_ASKPASS=/root/.vscode-server/cli/servers/Stable-4849ca9bdf9666755eb463db297b69e5385090e3/server/extensions/git/dist/askpass.sh GIT_EXEC_PATH=/usr/lib/git-core git config filter.lfs.process = "git-lfs filter-process" git config filter.lfs.smudge = "git-lfs smudge -- %f" git config filter.lfs.clean = "git-lfs clean -- %f"`

Traced output: `11:21:34.687277 trace git-lfs: attempting pure SSH protocol connection 11:21:34.687286 trace git-lfs: spawning pure SSH connection 11:21:34.687313 trace git-lfs: run_command: ssh -oControlMaster=yes -oControlPath=/run/user/0/sock-1864961435/lfs.sock root@{ip} git-lfs-transfer /home/ssh-test-project/test-project upload 11:21:34.687395 trace git-lfs: exec: ssh '-oControlMaster=yes' '-oControlPath=/run/user/0/sock-1864961435/lfs.sock' 'root@{ip}' 'git-lfs-transfer /home/ssh-test-project/test-project upload'

root@127.0.0.1's password:

11:21:37.527578 trace git-lfs: pure SSH connection successful

11:21:37.527596 trace git-lfs: pure SSH protocol connection failed: Unable to negotiate version with remote side (unable to read capabilities): EOF

11:21:37.527816 trace git-lfs: pre-push: refs/heads/master 9df4a7e6b476faf5f3585d79762ab76aa2b2c348 refs/heads/master 20881c844c531dfb28995b82dfdfce87664057c2

11:21:37.527890 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'show-ref'

11:21:37.529749 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'ls-remote' '--heads' '--tags' '-q' 'origin'

11:21:38.469988 trace git-lfs: attempting pure SSH protocol connection

11:21:38.470002 trace git-lfs: spawning pure SSH connection

11:21:38.470036 trace git-lfs: run_command: ssh -oControlMaster=yes -oControlPath=/run/user/0/sock-1640364680/lfs.sock root@{ip} git-lfs-transfer /home/ssh-test-project/test-project upload

11:21:38.470118 trace git-lfs: exec: ssh '-oControlMaster=yes' '-oControlPath=/run/user/0/sock-1640364680/lfs.sock' 'root@{ip}' 'git-lfs-transfer /home/ssh-test-project/test-project upload'

root@'s password:`

I tried to use git-lfs-transfer ssh -oControlMaster=yes -oControlPath=/run/user/0/sock-2282101820/lfs.sock root@{ip} /root/.cargo/bin/git-lfs-transfer /home/ssh-test-project/test-project upload output: `000eversion=1

0000`

Thanks again for your time and effort

chrisd8088 commented 1 month ago

Hey, I'm sorry you're having trouble. While the Git LFS client supports using SSH to transfer Git LFS objects to a remote service, not all Git LFS hosting services or software do so yet.

You don't specify which server software or service you're using, so we can't answer your question in detail.

If you're trying to use, for example, the lfs-test-server project (https://github.com/git-lfs/lfs-test-server), note that it does not support full SSH transfers of Git LFS objects yet. Neither does GitHub, but recent versions of GitLab do. So the answer will depend on what server or service you're trying to use.

Zherphy commented 1 month ago

Thanks for your explanation. This has really helped me a lot. Besides, I have another question I'd like to consult. If authentication using the SSH protocol by default fails, how can I set it up so that it automatically downgrades to the http/https protocol?

chrisd8088 commented 1 month ago

If authentication using the SSH protocol by default fails, how can I set it up so that it automatically downgrades to the http/https protocol?

That should happen automatically. When the Git LFS client attempts to communicate with an SSH endpoint, it first requests that the remote server run the git-lfs-transfer command, as described in the proposal for SSH support of Git LFS object transfers.

If that fails, the client falls back to requesting the git-lfs-authenticate command, which should then return HTTP authentication headers, which the Git LFS client will use for all subsequent communication and which it will perform over HTTP. The documentation for that process explains what the server should return from a git-lfs-authenticate request.

Zherphy commented 1 month ago

When I try this, output is: ssh: {ip[} failed, error: exit status 127, message: bash: line 1: git-lfs-authenticate: command not found Does it mean my LFS server need to deal this SSH operation(git-lfs-authenticate {path} {operation})? In other words, still need to connect to ssh?

chrisd8088 commented 1 month ago

Does it mean my LFS server need to deal this SSH operation(git-lfs-authenticate {path} {operation})?

Yes, if you want your server to support use of the Git LFS client in repositories with SSH remote URLs.

By which I mean, if a user clones a Git repository over SSH, then when they use Git LFS in that repository, by default (assuming no extra Git LFS configuration settings are made) the Git LFS client will start by connecting over SSH to the remote and requesting the git-lfs-authenticate command, in order to receive HTTP authentication headers it can then use for all subsequent communication.

I don't know what your situation is or what you're trying to do exactly, but typically Git LFS services are expected to provide support for clients to request the git-lfs-authenticate command.

Now if you're working in a controlled environment and don't need SSH support at all, you might not need your server to implement that support. For instance, if you can always set the lfs.url Git configuration value in your repositories, you can make that an HTTP URL, and then the Git LFS client will only use HTTP and won't bother starting with SSH and git-lfs-authenticate.

Zherphy commented 1 month ago

Your explanation and insights have been extremely valuable and have helped me a great deal. I truly appreciate the time and effort you took to provide such a detailed and helpful response.

I think I should focus on using HTTP URL directly.

Thanks again for your kindness and assistance.