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

Answered

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: git@github.com: Permission denied (publickey).: exit status 255
[14:59:06][Step 2/4] error: failed to fetch some objects from 'https://github.com/<>/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



3 comments
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.

0
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 

https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
I do not want to give my email id, but want to give a service account ?

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

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 .

0
Comment actions Permalink

Hi Sandeep,

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

teamcity.git.use.native.ssh

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

0

Please sign in to leave a comment.