Private repositories
ahto crawls a private repository with the login you already use for Git. It never prompts, never prints a token and keeps one only when you ask it to.
ssh
An ssh remote ([email protected]:org/repo.git) uses your ssh keys and agent, as git does.
lake.git.ssh_command sets the ssh command when the default is not right.
https
An https remote that asks for a login gets one from the first of these that has it:
- the URL itself (
https://user:token@host/org/repo; better kept out of shell history); lake.git.credentialsin the config, for a host and an optional path;- the
GH_TOKENandGITHUB_TOKENvariables (github.com,GITHUB_SERVER_URL,*.ghe.com),GH_ENTERPRISE_TOKENandGITHUB_ENTERPRISE_TOKEN(GH_HOST),GITLAB_TOKEN(gitlab.com orGITLAB_HOST) andCI_JOB_TOKEN(the GitLab CI server); - your git credential helpers (macOS keychain, Git Credential Manager, libsecret,
store,gh auth setup-git), asked withgit credential filland prompts off; gh auth tokenandglab config get tokenfor that host.
Sources 3 to 5 are read from your machine; lake.git.local_logins: false turns them off,
for a server that should use only its config. A login the remote refuses moves on to the
next source. ahto never prompts and never writes to a helper on its own.
ahto login
ahto login github.com # what each source holds (never the token)
ahto login https://git.example.com/org/repo # also check the remote takes it
ahto login --with-token git.example.com < token.txt # keep a token in your credential helperLogins in the config
For a server or CI, name the token in the config. The password is a secret: env, file
or command (the first line it prints, for a vault or a password manager):
lake:
git:
credentials:
- host: git.example.com
path: /platform # optional: only repositories under this path
password: {env: GIT_TOKEN}
- host: bitbucket.org
username: x-token-auth # the default user name is x-access-token
password: {command: [op, read, "op://ci/bitbucket/token"]}GitHub, GitHub Enterprise, GitLab (and self-managed), Gitea, Forgejo and Azure DevOps take a
token as the password with any user name; Bitbucket wants x-token-auth or your account name.
A token needs read access to the repository's contents; an organisation with SAML SSO also
wants the token authorized for it.
How a token is kept safe
- A login reaches
gitthrough an inline credential helper that answers only for that remote's host, so a redirect to another host never gets the token. - The token is passed in the environment of that one
gitprocess, never on its command line, and is never logged or printed, also not byahto login. - A remote URL is never written to a log or the lake with its password or token in it.
- ahto keeps a token only when you run
ahto login --with-token, and then in your own credential helper.