Skip to content

Cannot clone with non-default SSH key #2842

Closed

Description

@jmenashe

NOTE: In the following description I have changed some paths, project names,
and other identifying information, but left everything else intact.

NOTE 2: I would be happy to help implement a solution but I don't have a lot
of time. I will try to provide a fix myself but any tips/advice to get me started
would be very much appreciated.

I am having an issue where LFS fails to download large files when I use a specific SSH
key implicitly via the SSH config file. None of the following issues arise if I
use my default SSH key located at ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub; that is,
if I don't specify an SSH key and just clone from, say,
[email protected]:orgname/projectname.git, LFS works just fine. This leads
me to believe that the following issue has to do with a bug in LFS, rather than
my configuration.

In order to seamlessly integrate multiple SSH keys into my Git workflow,
I keep track of server/key associations using my ~/.ssh/config file.
For example:

Host bitbucket-personal
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_rsa.personal
  IdentitiesOnly yes

Host bitbucket-work
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_rsa.work
  IdentitiesOnly yes

Then, I have the following key pairs in my ~/.ssh directory:

$ ls id_* -la | awk '{print $9}'
id_rsa.work
id_rsa.work.pub
id_rsa.personal
id_rsa.personal.pub

This allows me to use different keys for different repositories:

git clone bitbucket-work:orgname/work-project.git # clones a work-related repo using my work key
git clone bitbucket-personal:jake/personal-project.git # clones a personal project repo using my personal key

Unfortunately, this causes problems when the cloned repository has files commited with LFS.
Below you will find the command line output followed by the full error log.

Command Line Output

$ git clone bitbucket-work:orgname/work-project.git
Cloning into 'work-project'...
remote: Counting objects: 7101, done.
remote: Compressing objects: 100% (2792/2792), done.
remote: Total 7101 (delta 5103), reused 6151 (delta 4228)
Receiving objects: 100% (7101/7101), 11.59 MiB | 1.44 MiB/s, done.
Resolving deltas: 100% (5103/5103), done.
Checking out files: 100% (1153/1153), done.
Downloading packages/PackageName/PackageLibrary.dll (478 KB)
Error downloading object: packages/PackageName/PackageLibrary.dll (deadbeef)                                                                                               : Smudge error: Error downloading packages/Atlas.DBLib/Interop.ATLAS_DBLib.dll (                                                                                               c7dc4024b6c32eb53765a3cfb35c98d7fd28a6aaa8c03260d95e928275734d36): batch request                                                                                               : missing protocol: "bitbucket-echo:echots/biv-braces.git/info/lfs"

Errors logged to C:\Code\orgname\work-project\.git\lfs\objects\logs\                                                                                               20180125T160052.6710708.log
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: packages/PackageName/PackageLibrary.dll: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

Error Log

git-lfs/2.3.4 (GitHub; windows amd64; go 1.8.3; git d2f6752f)
git version 2.16.1.windows.1

$ git-lfs.exe filter-process
Error downloading object: disable-restarts/disable-restart-task.pdf (a25f38e): Smudge error: Error downloading disable-restarts/disable-restart-task.pdf (a25f38e585dc2358b52c76684b419681a26e2b1d11de62f3688ac69892a4e1a0): batch request: missing protocol: "bitbucket-work:orgname/work-project.git/info/lfs"

missing protocol: "bitbucket-work:orgname/work-project.git/info/lfs"
batch request
github.com/git-lfs/git-lfs/errors.newWrappedError
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/types.go:170
github.com/git-lfs/git-lfs/errors.Wrap
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/errors.go:74
github.com/git-lfs/git-lfs/tq.(*tqClient).Batch
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/tq/api.go:55
github.com/git-lfs/git-lfs/tq.Batch
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/tq/api.go:37
github.com/git-lfs/git-lfs/tq.(*TransferQueue).enqueueAndCollectRetriesFor
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/tq/transfer_queue.go:426
github.com/git-lfs/git-lfs/tq.(*TransferQueue).collectBatches.func1
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/tq/transfer_queue.go:348
runtime.goexit
	C:/Go/src/runtime/asm_amd64.s:2197
Error downloading disable-restarts/disable-restart-task.pdf (a25f38e585dc2358b52c76684b419681a26e2b1d11de62f3688ac69892a4e1a0)
github.com/git-lfs/git-lfs/errors.newWrappedError
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/types.go:170
github.com/git-lfs/git-lfs/errors.Wrapf
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/errors.go:85
github.com/git-lfs/git-lfs/lfs.downloadFile
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/lfs/pointer_smudge.go:96
github.com/git-lfs/git-lfs/lfs.PointerSmudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/lfs/pointer_smudge.go:61
github.com/git-lfs/git-lfs/lfs.(*Pointer).Smudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/lfs/pointer.go:64
github.com/git-lfs/git-lfs/commands.smudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/command_smudge.go:128
github.com/git-lfs/git-lfs/commands.filterCommand
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/command_filter_process.go:116
github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(*Command).execute
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:477
github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(*Command).Execute
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:551
github.com/git-lfs/git-lfs/commands.Run
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/run.go:68
main.main
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/git-lfs.go:35
runtime.main
	C:/Go/src/runtime/proc.go:185
runtime.goexit
	C:/Go/src/runtime/asm_amd64.s:2197
Smudge error
github.com/git-lfs/git-lfs/errors.newWrappedError
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/types.go:170
github.com/git-lfs/git-lfs/errors.NewSmudgeError
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/errors/types.go:256
github.com/git-lfs/git-lfs/lfs.PointerSmudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/lfs/pointer_smudge.go:70
github.com/git-lfs/git-lfs/lfs.(*Pointer).Smudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/lfs/pointer.go:64
github.com/git-lfs/git-lfs/commands.smudge
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/command_smudge.go:128
github.com/git-lfs/git-lfs/commands.filterCommand
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/command_filter_process.go:116
github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(*Command).execute
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:477
github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra.(*Command).Execute
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/vendor/github.com/spf13/cobra/command.go:551
github.com/git-lfs/git-lfs/commands.Run
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/commands/run.go:68
main.main
	C:/Users/techn/go/src/github.com/git-lfs/git-lfs/git-lfs.go:35
runtime.main
	C:/Go/src/runtime/proc.go:185
runtime.goexit
	C:/Go/src/runtime/asm_amd64.s:2197

Current time in UTC: 
2018-01-26 00:23:06

ENV:
LocalWorkingDir=C:\Code\orgname\work-project
LocalGitDir=C:\Code\orgname\work-project\.git
LocalGitStorageDir=C:\Code\orgname\work-project\.git
LocalMediaDir=C:\Code\orgname\work-project\.git\lfs\objects
LocalReferenceDir=
TempDir=C:\Code\orgname\work-project\.git\lfs\tmp
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=C:\Code\orgname\work-project\.git\lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
GIT_DIR=.git
GIT_LFS_PATH=C:\Program Files\Git LFS

Activity

  1. deleted a comment from angkanasoisom on Feb 7, 2018
  2. deleted a comment from angkanasoisom on Feb 7, 2018
  3. deleted a comment from angkanasoisom on Feb 7, 2018
  4. ttaylorr commented on Feb 7, 2018

    @ttaylorr
    Contributor

    Hi @jmenashe, sorry that this issue has grown stale -- I'm not sure how I missed it! Most immediately, I think the issue is related to the repository URL (which Git accepts, but LFS does not). Can you prefix it with git@ to indicate to Git LFS that it is a SSH remote?

  5. jmenashe commented on Feb 13, 2018

    @jmenashe
    Author

    @ttaylorr Adding git@ before the SSH alias seems to have worked. I had assumed that this would conflict with the preset user in ~/.ssh/config, but it seems to not have been an issue.

    For anyone else wondering, I changed this:

    git clone bitbucket-work:orgname/work-project.git
    

    to this:

    git clone git@bitbucket-work:orgname/work-project.git
    
  6. ttaylorr commented on Feb 14, 2018

    @ttaylorr
    Contributor

    Glad that it works! Thanks again.

  7. sudoforge commented on Feb 18, 2018

    @sudoforge

    @ttaylorr While the workaround mentioned above works, would you consider support for better determination of the remote something that could make it into the development pipeline? If, using the original example, bitbucket-work is indeed a valid SSH host, I would assume that git-lfs should be able to clone from it successfully, without having to inconvenience the user by requiring the prefix of a username.

    I haven't looked at the project code myself, but would be happy to set some time aside in the near future and see if I can't get it working.


    To reiterate the issue, it appears that git-lfs has poor support for determining ssh hosts, requiring the user@hostname string to be in the remote. If someone has the following ssh configuration:

    ~/.ssh/config

    Host gh
        User git
        Hostname github.com
    

    ...It would be assumed that they clone their repositories using git clone gh:user/repo.git. Unfortunately, git-lfs doesn't recognize gh as a ssh host, because it is missing the user prefixed to the host - e.g. git@gh:user/repo.git (which works).

  8. ttaylorr commented on Feb 21, 2018

    @ttaylorr
    Contributor

    @ttaylorr While the workaround mentioned above works, would you consider support for better determination of the remote something that could make it into the development pipeline?

    Absolutely, but this isn't something that I have the bandwidth to take on myself for now. I've tentatively milestoned this into the next release, but I am not sure that I will be able to address it.

  9. added this to the v2.5.0 milestone on Feb 21, 2018
  10. deleted a comment from angkanasoisom on Feb 21, 2018
  11. mathstuf commented on Feb 21, 2018

    @mathstuf
    Contributor

    This is probably related to #2433.

  12. modified the milestones: v2.5.0, v2.6.0 on Jul 25, 2018
  13. docwhomc commented on Nov 12, 2026

    @docwhomc

    I just ran into this issue with git-lfs v. 3.8.1. Like jmenashe (author), I use multiple SSH keys (which I specify via SSH aliases).

    Note

    Like jmenashe, I have altered paths (by replacing my username with USERNAME) for privacy reasons.

    The workaround of prefixing the alias with a user (going from git clone DocW-GitHub:K0lb3/UnityPy.git to git clone git@DocW-GitHub:K0lb3/UnityPy.git) worked for me.

    Version Info

    $ git lfs version
    git-lfs/3.8.1 (GitHub; windows amd64; go 1.27.3; git a662a6db)
    

    ~/.ssh/config File

    Host *
        IdentityFile ~/.ssh/id_ed25519
    
    Host github.com
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_ed25519
    
    Host DocW-GitHub
        HostName github.com
        User git
        IdentityFile ~/.ssh/docw_id_ed25519
    

    Key Pairs in ~/.ssh Directory

    $ ls *id_* -la | awk '{print $9}'
    docw_id_ed25519
    docw_id_ed25519.pub
    id_ed25519
    id_ed25519.pub
    

    Command Line Input and Output

    $ git clone DocW-GitHub:K0lb3/UnityPy.git
    Cloning into 'UnityPy'...
    Enter passphrase for key '/c/Users/USERNAME/.ssh/docw_id_ed25519':
    remote: Enumerating objects: 5374, done.
    remote: Counting objects: 100% (1801/1801), done.
    remote: Compressing objects: 100% (586/586), done.
    remote: Total 5374 (delta 1500), reused 1215 (delta 1215), pack-reused 3573 (from 3)
    Receiving objects: 100% (5374/5374), 33.88 MiB | 7.10 MiB/s, done.
    Resolving deltas: 100% (3659/3659), done.
    Updating files: 100% (123/123), done.
    Downloading UnityPy/resources/lzma.tpk (208 KB)
    Error downloading object: UnityPy/resources/lzma.tpk (16f1f8b): Smudge error: Error downloading UnityPy/resources/lzma.tpk (16f1f8b809d1cd3bc3aeebf0cd43ecd3690b326a7a88b2273e57bcd83f5df608): batch request: ssh: Could not resolve hostname docw-github: Name or service not known: exit status 255
    
    Errors logged to 'D:\USERNAME\Games\UnityPy\.git\lfs\logs\20261112T144713.8700043.log'.
    Use `git lfs logs last` to view the log.
    error: external filter 'git-lfs filter-process' failed
    fatal: UnityPy/resources/lzma.tpk: smudge filter lfs failed
    warning: Clone succeeded, but checkout failed.
    You can inspect what was checked out with 'git status'
    and retry with 'git restore --source=HEAD :/'
    

    Error Log

    git-lfs/3.8.1 (GitHub; windows amd64; go 1.27.3; git a662a6db)
    git version 2.56.0.windows.4
    
    $ git-lfs.exe filter-process
    Error downloading object: UnityPy/resources/lzma.tpk (16f1f8b): Smudge error: Error downloading UnityPy/resources/lzma.tpk (16f1f8b809d1cd3bc3aeebf0cd43ecd3690b326a7a88b2273e57bcd83f5df608): batch request: ssh: Could not resolve hostname docw-github: Name or service not known: exit status 255
    
    batch request: ssh: Could not resolve hostname docw-github: Name or service not known: exit status 255
    Error downloading UnityPy/resources/lzma.tpk (16f1f8b809d1cd3bc3aeebf0cd43ecd3690b326a7a88b2273e57bcd83f5df608)
    github.com/git-lfs/git-lfs/v3/errors.newWrappedError
    	github.com/git-lfs/git-lfs/v3/errors/types.go:228
    github.com/git-lfs/git-lfs/v3/errors.Wrap
    	github.com/git-lfs/git-lfs/v3/errors/errors.go:74
    github.com/git-lfs/git-lfs/v3/lfs.(*GitFilter).downloadFile
    	github.com/git-lfs/git-lfs/v3/lfs/gitfilter_smudge.go:119
    github.com/git-lfs/git-lfs/v3/lfs.(*GitFilter).Smudge
    	github.com/git-lfs/git-lfs/v3/lfs/gitfilter_smudge.go:78
    github.com/git-lfs/git-lfs/v3/commands.smudge
    	github.com/git-lfs/git-lfs/v3/commands/command_smudge.go:128
    github.com/git-lfs/git-lfs/v3/commands.filterCommand
    	github.com/git-lfs/git-lfs/v3/commands/command_filter_process.go:132
    github.com/spf13/cobra.(*Command).execute
    	github.com/spf13/[email protected]/command.go:1019
    github.com/spf13/cobra.(*Command).ExecuteC
    	github.com/spf13/[email protected]/command.go:1148
    github.com/spf13/cobra.(*Command).Execute
    	github.com/spf13/[email protected]/command.go:1071
    github.com/git-lfs/git-lfs/v3/commands.Run
    	github.com/git-lfs/git-lfs/v3/commands/run.go:154
    main.main
    	github.com/git-lfs/git-lfs/v3/git-lfs.go:31
    runtime.main
    	runtime/proc.go:302
    runtime.goexit
    	runtime/asm_amd64.s:1264
    Smudge error
    github.com/git-lfs/git-lfs/v3/errors.newWrappedError
    	github.com/git-lfs/git-lfs/v3/errors/types.go:228
    github.com/git-lfs/git-lfs/v3/errors.NewSmudgeError
    	github.com/git-lfs/git-lfs/v3/errors/types.go:314
    github.com/git-lfs/git-lfs/v3/lfs.(*GitFilter).Smudge
    	github.com/git-lfs/git-lfs/v3/lfs/gitfilter_smudge.go:95
    github.com/git-lfs/git-lfs/v3/commands.smudge
    	github.com/git-lfs/git-lfs/v3/commands/command_smudge.go:128
    github.com/git-lfs/git-lfs/v3/commands.filterCommand
    	github.com/git-lfs/git-lfs/v3/commands/command_filter_process.go:132
    github.com/spf13/cobra.(*Command).execute
    	github.com/spf13/[email protected]/command.go:1019
    github.com/spf13/cobra.(*Command).ExecuteC
    	github.com/spf13/[email protected]/command.go:1148
    github.com/spf13/cobra.(*Command).Execute
    	github.com/spf13/[email protected]/command.go:1071
    github.com/git-lfs/git-lfs/v3/commands.Run
    	github.com/git-lfs/git-lfs/v3/commands/run.go:154
    main.main
    	github.com/git-lfs/git-lfs/v3/git-lfs.go:31
    runtime.main
    	runtime/proc.go:302
    runtime.goexit
    	runtime/asm_amd64.s:1264
    
    Current time in UTC:
    2026-11-12 19:47:13
    
    Environment:
    LocalWorkingDir=D:\USERNAME\Games\UnityPy
    LocalGitDir=D:\USERNAME\Games\UnityPy\.git
    LocalGitStorageDir=D:\USERNAME\Games\UnityPy\.git
    LocalMediaDir=D:\USERNAME\Games\UnityPy\.git\lfs\objects
    LocalReferenceDirs=
    TempDir=D:\USERNAME\Games\UnityPy\.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=D:\USERNAME\Games\UnityPy\.git\lfs
    AccessDownload=none
    AccessUpload=none
    DownloadTransfers=basic,lfs-standalone-file,ssh
    UploadTransfers=basic,lfs-standalone-file,ssh
    GIT_ASKPASS=c:\Users\USERNAME\AppData\Roaming\Code\User\globalStorage\vscode.git\askpass\70789581cae28aa7\askpass.sh
    GIT_DIR=D:/USERNAME/Games/UnityPy/.git
    GIT_EXEC_PATH=C:/Program Files/Git/ucrt64/libexec/git-core
    
    Client IP addresses:
    fe80::c55f:de06:f7ef:ee4f 192.168.86.30
    fe80::b44e:5fad:8a02:8f5a 172.27.32.1
    
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions