github.com/atlassian/git-lob@v0.0.0-20150806085256-2386a5ed291a/doc/git-lob-serve.md (about)

     1  # The git-lob-serve reference server #
     2  
     3  While git-lob can sync to simple server storage locations like filesystem and s3, for the full range of functionality a 'smart' server implementation is required (see [The Smart Sync Protocol](smart_protocol.md)). ```git-lob-serve``` is a reference implementation of this server which is suitable for running over an SSH connection from a client. 
     4  
     5  When using the 'smart' sync provider and using an SSH URL (either ssh://user@host/path or user@host:/path), git-lob will automatically open an SSH connection to the host specified and run the command specified by the config parameter ```git-lob.ssh-server```, which if not specified defaults to ```git-lob-serve```. Simply copying this program onto your server (no dependencies required, it's stand-alone and works on Windows, Linux and Mac servers) and providing authenticated SSH users access to it is enough to provide a reference implementation of a smart server on your own host.
     6  
     7  ## Installation ##
     8  
     9  From the root, build the server in whatever architecture you want using gox (https://github.com/mitchellh/gox) and upload the binary to your server's path:
    10  ```
    11  gox -build-toolchain
    12  gox -osarch="linux/386" ./git-lob-serve
    13  scp git-lob-serve_linux_386 admin@host.com:/usr/local/bin/git-lob-serve
    14  ```
    15  
    16  Make sure the user you'll be using to connect has access to this binary and also the base path (see configuration below).
    17  
    18  ## sshd configuration for groups ##
    19  
    20  On many Linux distros, 'ssh url command' uses a default umask of 022 which means that uploaded file permissions are read only except for the user. If you want people to use their own username in their SSH url & give permission to files via groups, you should edit /etc/pam.d/sshd and add:
    21  ```
    22  # Setting UMASK for all ssh based connections (ssh, sftp, scp)
    23  # always allow group perms
    24  session    optional     pam_umask.so umask=0002
    25  ```
    26  git-lob-serve will copy the permissions of the base path when creating new files & directories but it can't do that if the umask filters out the write bits. You can't fix this with 'umask' in /etc/profile because that only applies to interactive ssh terminals, not 'ssh url command' forms.
    27  
    28  ## Invocation ##
    29  
    30  git-lob will generally handle this, but to invoke the server binary you simply need to run it by name and pass a single 'path' argument. This path is to support multiple binary stores on the remote server end; you might want to have a separate binary store for each repo, or for each user, or for each team, or just a single path for everything (binaries are immutable so technically can be shared between everyone, if permissions aren't an issue).
    31  
    32  When given an SSH URL for the remote store, git-lob will simply strip off the path element and pass that as an argument to git-lob-serve over the SSH connection. It's up to you to use an SSH URL that reflects how you want to partition up the remote binary store(s).
    33  
    34  Examples:
    35  
    36  | URL | Server command |
    37  |-----|----------------|
    38  |ssh://steve@bighost.com/goteam/repo1|```git-lob-serve goteam/repo1```|
    39  |git@thehost.com:projects/newproject|```git-lob-serve projects/newproject```|
    40  |ssh://andy@bighost.com//var/shared/rooted/repo|```git-lob-serve /var/shared/rooted/repo``` (disallowed by default config)|
    41  
    42  Rooted paths are disallowed by the default configuration for security, forcing all repositories to be under a base path (see below).
    43  
    44  ## Configuration files ##
    45  
    46  Configuration is via a simple key-value text file placed in the following locations:
    47  
    48  Windows:
    49  
    50  * %USERPROFILE%\git-lob-serve.ini
    51  * %PROGRAMDATA%\Atlassian\git-lob\git-lob-serve.ini
    52  
    53  Linux/Mac:
    54  
    55  * ~/.git-lob-serve
    56  * /etc/git-lob-serve.conf
    57  
    58  Usually you'll want to use a global config file to avoid each user having to configure it themselves, unless you use a generic user name for all connections and want to keep the settings there instead of system-wide.
    59  
    60  ## Configuration settings ##
    61  
    62  There are no grouping levels in the configuration file, it's just a simple name = value style.
    63  
    64  | Setting | Description | Default |
    65  |---------|-------------|---------|
    66  |base-path|The base directory of the binary store. Paths passed as arguments will be evaluated relative to this directory, unless they're intentionally rooted (disallowed by default, see allow-absolute) |None|
    67  |allow-absolute-paths|Whether to allow absolute paths as arguments, i.e. rooted paths which go outside base-path. Not advisable to enable since can be a security risk.|False|
    68  |enable-delta-receive|Whether to support receiving binary deltas to save upload time at the expense of some CPU/Memory usage to apply them. Applying patches is not as costly as generating them which is why there are separate settings|True|
    69  |enable-delta-send|Whether to support generating deltas between binaries for clients to download. Generating deltas can be costly so you may want to disable this if you're finding it too much of an overhead.|True|
    70  |delta-cache-path|Where to store cached deltas between versions, to avoid having to recalculate them all the time|$base-path/.deltacache|
    71  |delta-size-limit|The maximum size file that we will attempt to use as a base for calculating a binary delta. Large files can use a lot of memory to calculate deltas on, so this limits what we attempt to use as a base. We still calculate deltas above this size but only the first X bytes are used as a base, meaning the diff can be a little less optimal at the expense of a known max memory overhead. |2147483648 (2GB)|
    72  
    73  
    74  
    75