Skip to content

SSH protocol not correctly detected, leading to 'Unsupported protocol scheme' error #2255

Closed

Description

@krukai

It seems that for Git LFS to detect the SSH protocol, it is necessary to either provide ssh:// or use the username@host syntax. If the repository URL is lacking both, the first part of the hostname will be taken as the protocol name.

For example, somehost.com:myrepo.git might be a perfectly valid repository URL to clone from if my username is either identical or is provided through the ssh config.

In my case, I provide the SSH user name through my SSH config when cloning from BitBucket. The files tracked by LFS are not on the master branch, so I run into errors as soon as I checkout a branch that does.

So when cloning with git clone bitbucket.org:user/project, I get the following error when checking out the branch with files tracked by Git LFS:

git-lfs/2.2.0-pre (GitHub; linux amd64; go 1.8.1)
git version 2.13.0

$ git-lfs filter-process
Error downloading object: Assets/somemodel.fbx (...): Smudge error: Error downloading Assets/somemodel.fbx (...): batch response: Post bitbucket.org:user/project.git/info/lfs/objects/batch: unsupported protocol scheme "bitbucket.org"

Post bitbucket.org:user/project.git/info/lfs/objects/batch: unsupported protocol scheme "bitbucket.org"
...

Providing the username during cloning apparently makes the protocol being recognized (git is the user for all SSH connections on BitBucket):
git clone [email protected]:user/project

Providing the protocol itself works as well:
git clone ssh://bitbucket.org/user/project

Changing the URLs after cloning would also be a work-around, I assume, but I hope this is fixed for the sake of integrating Git LFS better with Git itself.
This was documented on Arch Linux, but I faintly remember running into similar issues on Windows a while ago that I did not further looked into back then.

Activity

  1. ttaylorr commented on May 23, 2017

    @ttaylorr
    Contributor

    👋 @krukai, thanks for opening this. I think the function that needs changing is this one, and in particular, these lines[1]:

    host := match[1]
    if u.User != nil && u.User.Username() != "" {
    	endpoint.SshUserAndHost = fmt.Sprintf("%s@%s", u.User.Username(), host)
    } else {
    	endpoint.SshUserAndHost = host
    }

    I don't have time to address this right now, but I've milestoned this issue into the v2.2.0 milestone, so it should be addressed and fixed by the time that release is cut. In the meantime, you can work around this by providing an SSH username, using an HTTPs remote, or using the environment variable GIT_LFS_SKIP_SMUDGE to skip the checkout entirely.

  2. added this to the v2.2.0 milestone on May 23, 2017
  3. modified the milestones: v2.2.0, v2.3.0 on Jul 5, 2017
  4. hjmallon commented on Sep 7, 2017

    @hjmallon

    I have just seen this issue while evaluating git LFS. I think it is stopping git-lfs from correctly using git-lfs-authenticate. I have never written any go before so apologies if this is somehow wrong.

    We generally use ssh config with Gerrit here. e.g.

    Host gerrit
        HostName 192.168.1.1
        Port 29418
        User user.name
        IdentityFile ~/.ssh/id_rsa
    

    Using go default URL parsing "u.Scheme" comes out as "gerrit". I have a test program which can make the SSH aliases into bare SSH URLs.

    package main
    import "fmt"
    import "net/url"
    import "github.com/kevinburke/ssh_config"
    
    func main() {
        s := "gerrit:repo.git"
        u, err := url.Parse(s)
        if err != nil {
            panic(err)
        }
    
        port, err := ssh_config.GetStrict(u.Scheme, "Port")
        if err != nil {
            panic(err)
        }
    
        hostname, err := ssh_config.GetStrict(u.Scheme, "HostName")
        if err != nil {
            panic(err)
        }
    
        user, err := ssh_config.GetStrict(u.Scheme, "User")
        if err != nil {
            panic(err)
        }
    
        output := s
        if hostname != "" {
            output = user + "@" + hostname + ":" + port
        }
    
        fmt.Println("Original: " + s)
        fmt.Println("Parsed: " + output)
    }
    

    It requires ssh_config package.
    https://godoc.org/github.com/kevinburke/ssh_config
    https://github.com/kevinburke/ssh_config

    This returns

    % go run test.go
    Original: gerrit:repo.git
    Parsed: [email protected]:29418
    

    This issue was mentioned in previous discussion of a different issue (#930)

  5. modified the milestones: v2.4.0, v2.3.0 on Sep 8, 2017
  6. ttaylorr commented on Sep 8, 2017

    @ttaylorr
    Contributor

    @hjmallon great find, and thank you for spending some time on this! I don't have time to work on this right now, but would be more than happy to help offer some pointers on how to integrate the snippet that you posted above (and with my comment in #2255 (comment)) into LFS.

    Please let me know if this is something that you (or somebody else) would be interested, and we can get started.

  7. removed this from the v2.4.0 milestone on Sep 27, 2017
  8. ttaylorr commented on Jul 27, 2018

    @ttaylorr
    Contributor

    Moving to #278.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions