| 1 | # Authentication |
| 2 | |
| 3 | The Git LFS API uses HTTP Basic Authentication to authorize requests. Therefore, |
| 4 | HTTPS is strongly encouraged for all production Git LFS servers. The credentials |
| 5 | can come from the following places: |
| 6 | |
| 7 | ## SSH |
| 8 | |
| 9 | Git LFS will add any HTTP headers returned from the `git-lfs-authenticate` |
| 10 | command to any Batch API requests. If servers are returning expiring tokens, |
| 11 | they can add an `expires_in` (or `expires_at`) property to hint when the token |
| 12 | will expire. |
| 13 | |
| 14 | ```bash |
| 15 | # Called for remotes like: |
| 16 | # * [email protected]:foo/bar.git |
| 17 | # * ssh://[email protected]/foo/bar.git |
| 18 | $ ssh [email protected] git-lfs-authenticate foo/bar.git download |
| 19 | { |
| 20 | "header": { |
| 21 | "Authorization": "RemoteAuth some-token" |
| 22 | }, |
| 23 | |
| 24 | # optional, for expiring tokens, preferred over expires_at |
| 25 | "expires_in": 86400, |
| 26 | |
| 27 | # optional, for expiring tokens |
| 28 | "expires_at": "2016-11-10T15:29:07Z" |
| 29 | } |
| 30 | ``` |
| 31 | |
| 32 | See the SSH section in the [Server Discovery doc](./server-discovery.md) for |
| 33 | more info about `git-lfs-authenticate`. |
| 34 | |
| 35 | ## Git Credentials |
| 36 | |
| 37 | Git provides a [`credentials` command](https://git-scm.com/docs/gitcredentials) |
| 38 | for storing and retrieving credentials through a customizable credential helper. |
| 39 | By default, it associates the credentials with a domain. You can enable |
| 40 | `credential.useHttpPath` so different repository paths have different |
| 41 | credentials. |
| 42 | |
| 43 | Git ships with a really basic credential cacher that stores passwords in memory, |
| 44 | so you don't have to enter your password frequently. However, you are encouraged |
| 45 | to setup a [custom git credential cacher](https://help.github.com/articles/caching-your-github-password-in-git/), |
| 46 | if a better one exists for your platform. |
| 47 | |
| 48 | As of version 3.0, Git LFS no longer supports NTLM. Users are encouraged to set up |
| 49 | Kerberos; for example, Azure DevOps Server recommends Kerberos over NTLM in |
| 50 | [this blog post](https://devblogs.microsoft.com/devops/reconfigure-azure-devops-server-to-use-kerberos-instead-of-ntlm/). |
| 51 | For pre-3.0 LFS versions, if your Git LFS server authenticates with NTLM then you |
| 52 | must provide your credentials to `git-credential` in the form |
| 53 | `username:DOMAIN\user password:password`. |
| 54 | |
| 55 | ## Specified in URL |
| 56 | |
| 57 | You can hardcode credentials into your Git remote or LFS url properties in your |
| 58 | git config. This is not recommended for security reasons because it relies on |
| 59 | the credentials living in your local git config. |
| 60 | |
| 61 | ```bash |
| 62 | $ git remote add origin https://user:[email protected]/foo/bar.git |
| 63 | ``` |