Rhiza fetches template files by running git clone under the hood. If your template repository is private, Git needs credentials to access it. This guide explains how to configure authentication for GitHub and GitLab template repositories.
- GitHub Authentication
- GitLab Authentication
- CI/CD Configuration
- Verifying Your Setup
- Troubleshooting
The GitHub CLI is the easiest way to configure Git credentials locally. It handles token management automatically.
# Install the GitHub CLI
# macOS
brew install gh
# Ubuntu / Debian
sudo apt install gh
# Windows (winget)
winget install GitHub.cli
# Authenticate
gh auth login
# Configure git to use the CLI's credentials
gh auth setup-gitAfter running gh auth setup-git, all git clone operations (including those run by rhiza sync) will automatically use your GitHub credentials.
If you prefer not to install the GitHub CLI, you can use a Personal Access Token (PAT).
Fine-grained token (recommended):
- Go to GitHub Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Click Generate new token
- Set a descriptive name (e.g.,
rhiza-templates-read) - Set an expiration date (90 days or less is recommended)
- Under Repository access, select only the template repository
- Under Repository permissions, grant Contents: Read-only
- Click Generate token and copy the token immediately
Classic token:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Set a descriptive name (e.g.,
rhiza-templates-read) - Set an expiration date
- Select the
reposcope (required for private repository access) - Click Generate token and copy the token immediately
Store the token in your Git credential store so it is used automatically:
# Configure git to use the token for GitHub HTTPS URLs
git config --global credential.helper store
echo "https://YOUR_TOKEN@github.com" >> ~/.git-credentialsOr use a more secure credential helper (macOS Keychain, Windows Credential Manager):
# macOS — uses Keychain
git config --global credential.helper osxkeychain
# Windows — uses Windows Credential Manager
git config --global credential.helper managerThen clone any private GitHub repository to trigger the credentials prompt, enter your username and the token as the password, and the helper will cache them.
Alternatively, embed the token directly in the Git URL rewrite rule (keep this out of version control):
git config --global url."https://YOUR_TOKEN@github.com/".insteadOf "https://github.com/"Security note: Embedding tokens in Git config stores them in plain text in
~/.gitconfig. Prefer the credential helper approach or the GitHub CLI for better security.
SSH keys are a good choice for long-term local development setups.
ssh-keygen -t ed25519 -C "your_email@example.com"
# Press Enter to accept the default file location (~/.ssh/id_ed25519)
# Optionally set a passphrase- Copy the public key:
cat ~/.ssh/id_ed25519.pub - Go to GitHub Settings → SSH and GPG keys
- Click New SSH key
- Paste the public key and save
Update .rhiza/template.yml to use an SSH-compatible URL format. Rhiza uses the owner/repo format internally, but you can set the host to control which URL prefix is used. For SSH you can override git's URL rewriting:
# Rewrite HTTPS GitHub URLs to SSH (applies globally)
git config --global url."git@github.com:".insteadOf "https://github.com/"After this, rhiza sync will use SSH for all GitHub clones automatically.
- Go to your GitLab profile → Edit profile → Access tokens (or navigate to
https://gitlab.com/-/profile/personal_access_tokens) - Click Add new token
- Set a descriptive name (e.g.,
rhiza-templates-read) - Set an expiration date
- Select the
read_repositoryscope - Click Create personal access token and copy the token immediately
# Store the token using git credential helper
git config --global credential.helper store
echo "https://oauth2:YOUR_TOKEN@gitlab.com" >> ~/.git-credentialsOr use the URL rewrite approach:
git config --global url."https://oauth2:YOUR_TOKEN@gitlab.com/".insteadOf "https://gitlab.com/"ssh-keygen -t ed25519 -C "your_email@example.com"- Copy the public key:
cat ~/.ssh/id_ed25519.pub - Go to your GitLab profile → Edit profile → SSH Keys
- Paste the key and save
# Rewrite HTTPS GitLab URLs to SSH
git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"When running rhiza sync in GitHub Actions against a private template repository in the same organization, the default GITHUB_TOKEN may be sufficient:
- name: Sync Rhiza templates
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
uvx rhiza syncFor private template repositories in a different organization, or when the default token lacks access, use a Personal Access Token stored as a repository secret:
- name: Sync Rhiza templates
run: |
git config --global url."https://${{ secrets.RHIZA_TEMPLATE_TOKEN }}@github.com/".insteadOf "https://github.com/"
uvx rhiza syncTo add a secret to your repository:
- Go to your repository → Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
RHIZA_TEMPLATE_TOKEN - Value: paste your PAT
- Click Add secret
For private GitLab template repositories in the same instance, use the built-in CI token:
sync_templates:
script:
- git config --global url."https://oauth2:${CI_JOB_TOKEN}@gitlab.com/".insteadOf "https://gitlab.com/"
- uvx rhiza syncFor cross-instance or cross-group access, use a Project Access Token or Group Access Token stored as a CI/CD variable:
sync_templates:
script:
- git config --global url."https://oauth2:${RHIZA_TEMPLATE_TOKEN}@gitlab.com/".insteadOf "https://gitlab.com/"
- uvx rhiza syncAfter configuring credentials, verify that Git can access your template repository before running rhiza sync:
# Replace with your actual template repository
git ls-remote https://github.com/myorg/my-templates.gitIf the command lists refs without prompting for a password, your credentials are correctly configured. You can then run rhiza sync normally.
Git cannot find any credentials for the URL. Choose one of the authentication options above and configure it before retrying.
This can mean either:
- The repository does not exist or the
owner/repopath intemplate.ymlis incorrect - The credentials are valid but the token does not have access to the repository (check token scopes)
- The repository is private and no credentials are configured at all
Your SSH key is not recognised by the server. Verify that:
- The public key (
~/.ssh/id_ed25519.pub) has been added to your GitHub/GitLab account - The SSH agent is running and the key is loaded:
ssh-add ~/.ssh/id_ed25519 - You can reach the host:
ssh -T git@github.com
Tokens have expiry dates. If rhiza sync suddenly fails after working previously, check whether your PAT has expired and generate a new one.
Ensure the secret containing your token is:
- Correctly named in the workflow YAML (e.g.,
secrets.RHIZA_TEMPLATE_TOKEN) - Available to the workflow (organization secrets may need to be explicitly shared with repositories)
- Not expired
.rhiza/docs/TOKEN_SETUP.md— PAT setup for the automated Rhiza sync workflow.rhiza/docs/PRIVATE_PACKAGES.md— Using private Python packages as dependencies- GitHub: Creating a personal access token
- GitLab: Personal access tokens
- GitHub: SSH key setup
- GitLab: SSH key setup