Skip to content

git lfs with ssh #2475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
laoshaw opened this issue Sep 8, 2017 · 6 comments
Closed

git lfs with ssh #2475

laoshaw opened this issue Sep 8, 2017 · 6 comments
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Comments

@laoshaw
Copy link

laoshaw commented Sep 8, 2017

To get git-lfs working with ssh/scp it can be redirected to http/https as native ssh support is not implemented upstream, below is related info:

https://github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md#using-a-custom-transfer-type-without-the-api-server

git-lfs/git-lfs#1044

@bkcsoft bkcsoft added type/enhancement An improvement of existing functionality type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Sep 8, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Sep 8, 2017

Those transfer-hooks are client-side so we can't make that happen unfortunately. Only way to get real SSH-support is to get it upstream in the issue you linked :(

@bkcsoft
Copy link
Member

bkcsoft commented Sep 8, 2017

The only solution today is to have SSH return a JSON-payload for redirecting it to HTTP(S) git-lfs/git-lfs#1044 (comment) which is fairly straight forward to add:

@stale
Copy link

stale bot commented Feb 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 13, 2019
@lunny lunny added issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented and removed issue/stale labels Feb 13, 2019
@ukos-git
Copy link

I can not get ssh authentification to work so I guess this is still an open issue

I don't know where to start for the solution proposed by @bkcsoft .

gitea/cmd/serv.go

Lines 137 to 147 in b03d780

if verb == lfsAuthenticateVerb {
if !setting.LFS.StartServer {
fail("Unknown git command", "LFS authentication request over SSH denied, LFS support is disabled")
}
argsSplit := strings.Split(args, " ")
if len(argsSplit) >= 2 {
args = strings.TrimSpace(argsSplit[0])
lfsVerb = strings.TrimSpace(argsSplit[1])
}
}

Can you look again at ssh authentification for lfs in gitea @fabian-z @lunny

@fabian-z
Copy link
Contributor

fabian-z commented Feb 27, 2019

Well, we should already be doing what @bkcsoft suggested and it worked in my original tests.

This code is responsible for implementing server discovery by returning the proper URL and authentication token if called via SSH:

gitea/cmd/serv.go

Lines 292 to 326 in b03d780

if verb == lfsAuthenticateVerb {
url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, username, repo.Name)
now := time.Now()
claims := jwt.MapClaims{
"repo": repo.ID,
"op": lfsVerb,
"exp": now.Add(setting.LFS.HTTPAuthExpiry).Unix(),
"nbf": now.Unix(),
}
if user != nil {
claims["user"] = user.ID
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
// Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString(setting.LFS.JWTSecretBytes)
if err != nil {
fail("Internal error", "Failed to sign JWT token: %v", err)
}
tokenAuthentication := &models.LFSTokenResponse{
Header: make(map[string]string),
Href: url,
}
tokenAuthentication.Header["Authorization"] = fmt.Sprintf("Bearer %s", tokenString)
enc := json.NewEncoder(os.Stdout)
err = enc.Encode(tokenAuthentication)
if err != nil {
fail("Internal error", "Failed to encode LFS json response: %v", err)
}
return nil
}

It seems there is some confusion about the subject of this issue.

One aspect is server discovery / authentication using SSH. This should be implemented and working according to the LFS API docs.

Another one is transfer of data with SSH instead of HTTPS. This is currently not part of the LFS specification and therefore also not implemented, still to be decided upstream (see git-lfs/git-lfs#1044)

@ukos-git: Could you elaborate on what part of SSH authentication is not working for you? What did you do, what errors are you getting? Please make sure your server has a working HTTPS configuration.

@laoshaw: Are you only asking for a pure SSH based transport without HTTPS (as in the linked git-lfs issue)? Do you experience issues when using SSH remotes? Please also make sure your server has a working HTTPS configuration.

@ukos-git
Copy link

Authentification is working now.

ssh ssh://git@mygitproject git-lfs-authenticate user/repo download
{
  "header": {
    "Authorization": "Bearer XYZ"
  },
  "href": "https://mygitproject/user/repo.git/info/lfs"
}

I got probably confused during the setup.

Since the gitea implementation is actually working, we should close this issue here. implementation of scp is an upstream git-lfs problem.

@lunny lunny removed this from the 1.x.x milestone Feb 28, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

No branches or pull requests

6 participants