How to use git lfs with Teamcity / git lfs fetch --all give Permission denied (publickey).: exit status 255 ?


Currently while using git LFS with teamcity I face an issue while doing the below ?

git add .gitattributes
GIT_TRACE=1 git lfs fetch --all
git lfs pull

I get the below error, 

14:59:05][Step 2/4] + cat /root/.ssh/config
[14:59:05][Step 2/4] + git lfs fetch --all

I have set StrictHostKeyChecking set to `no` , on the ~/.ssh/config file . 

[14:59:05][Step 2/4] Host *
[14:59:05][Step 2/4] StrictHostKeyChecking no
[14:59:05][Step 2/4] Scanning for all objects ever referenced...
[14:59:05][Step 2/4]
[14:59:05][Step 2/4] / 1 objects found
[14:59:05][Step 2/4] - 2 objects found
[14:59:05][Step 2/4] \ 3 objects found
[14:59:05][Step 2/4] | 4 objects found
[14:59:05][Step 2/4] / 5 objects found
[14:59:05][Step 2/4] - 6 objects found
[14:59:05][Step 2/4] \ 7 objects found
[14:59:05][Step 2/4] | 8 objects found
[14:59:05][Step 2/4] ✔ 8 objects found
[14:59:05][Step 2/4] Fetching objects...
[14:59:06][Step 2/4] batch request: Permission denied (publickey).: exit status 255
[14:59:06][Step 2/4] error: failed to fetch some objects from '<>/info/lfs'
[14:59:06][Step 2/4]
[14:59:06][Step 2/4] Git LFS: (0 of 2 files) 0 B / 87.98 MB

Comment actions Permalink

Hi Sandeep,

Do you execute git lfs via a command-line runner?

This error indicates that the public key your agent is sending to GitHub is invalid. Try executing the same commands on the agent outside of TeamCity. If results will be the same outside of TeamCity, then it means you should configure your git lfs to use the proper key.

Comment actions Permalink

yeah I can configure git lfs on my Local machine (not the teamcity agent) , can you outline the process on how to configure git LFS on a Teamcity Agent, do note the local machine, I am the user and hence I can always auth, in the Teamcity agent I do not want to login and do something as such
I do not want to give my email id, but want to give a service account ?

ssh-keygen -t rsa -b 4096 -C ""

Yeah within the Teamcity agent also I cannot auth as well, if I do need to auth I would need to do the process outline above , generate a Keypair and go from there, what is the recommended way here to use git lfs .

Comment actions Permalink

Hi Sandeep,

Could you please check if setting the below build configuration parameter to true resolves the issue for you?


In TW-55655 a similar problem was resolved via this configuration parameter.


Please sign in to leave a comment.