Git credentials v23.40.0
This page explains how to clone Git repositories that require authentication.
This may be required when you change postgres_git_url
to install Postgres from source or
use install_from_source to compile and
install extensions.
You have two options to authenticate without writing the credentials to disk on the target instance:
For an
ssh://repository, you can add an SSH key to your local ssh-agent. Agent forwarding is enabled by default if you use--install-from-source(forward_ssh_agent: yesin config.yml).For an
https://repository, you canexport TPA_GIT_CREDENTIALS=username:tokenin your environment before runningtpaexec deploy.
Note
When deploying to Docker on macOS, you should use only https://
repository URLs because Docker containers cannot be accessed by ssh
from the host in this environment.
SSH key authentication
If you are cloning an SSH repository and have an SSH keypair
(id_example and id_example.pub), use SSH agent forwarding to
authenticate on the target instances:
You need to run
ssh-agentlocally. If your desktop environment does not already set this up for you (as most do—pgrep ssh-agentto check if it's running), runssh-agent bashto temporarily start a new shell with the agent enabled, and runtpaexec deployfrom that shell.Add the required key(s) to the agent with
ssh-add /path/to/id_example(the private key file)Enable SSH agent forwarding by setting
forward_ssh_agent: yesat the top level in config.yml beforetpaexec provision. (This is done by default if you use--install-from-source.)
During deployment, any keys you add to your agent will be made available for authentication to remote servers through the forwarded agent connection.
Use SSH agent forwarding with caution, preferably with a disposable keypair generated specifically for this purpose. Users with the privileges to access the agent's Unix domain socket on the target server can co-opt the agent into impersonating you while authenticating to other servers.
HTTPS username/password authentication
If you are cloning an HTTPS repository with a username and
authentication token or password, just
export TPA_GIT_CREDENTIALS=username:token in your environment before
tpaexec deploy. During deployment, these credentials will be made
available to any git clone or git pull tasks (only). They will
not be written to disk on the target instances.