GitHub Actions `checkout` Action Authentication Failure on Windows WSL2 Ubuntu: A Deep Dive & Fix
Resolve 'GitHub Actions checkout action repository authentication failed' when using Git in WSL2 Ubuntu with private GitHub repos.
Resolve 'GitHub Actions checkout action repository authentication failed' when using Git in WSL2 Ubuntu with private GitHub repos.
When developing on Windows using the Windows Subsystem for Linux 2 (WSL2) with an Ubuntu distribution, you might encounter frustrating authentication failures when attempting to interact with private Git repositories, particularly those hosted on GitHub. While the error message might resemble a "GitHub Actions checkout action repository authentication failed," it often points to a local Git configuration issue within your WSL2 environment, where your Git client cannot properly authenticate with GitHub (or other Git providers). This guide will help you diagnose and resolve these authentication challenges.
Symptom & Error Signature
You are typically running git clone, git fetch, or git pull commands from your WSL2 Ubuntu terminal against a private GitHub repository, and the operation fails with an authentication error. This issue is distinct from an actual GitHub Actions workflow failing on a GitHub runner; rather, it's about your local WSL2 environment failing to authenticate in a manner analogous to what a checkout action does.
Common error outputs include:
Cloning into 'my-private-repo'...
fatal: Authentication failed for 'https://github.com/my-org/my-private-repo.git/'
Or, if you're using an older Git client or haven't configured a credential helper:
Cloning into 'my-private-repo'...
Username for 'https://github.com': <your-github-username>
Password for 'https://[email protected]':
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
fatal: Authentication failed for 'https://github.com/my-org/my-private-repo.git/'
Root Cause Analysis
The core of this problem lies in the fundamental architectural separation between your Windows host environment and your WSL2 Linux guest environment, specifically concerning Git credential management.
- Separate Git Environments: When you install Git on Windows, it typically comes bundled with a credential helper, most commonly Git Credential Manager Core (GCM Core). This helper integrates deeply with Windows' credential store, allowing Git to securely store and retrieve your GitHub Personal Access Tokens (PATs) or other authentication tokens.
- WSL2 Isolation: Your Ubuntu distribution inside WSL2 is a distinct Linux environment. When you install Git within WSL2 (e.g., via
sudo apt install git), it's a fresh Git installation. By default, this Linux Git client has no direct access to the Windows credential store or the Windows-native GCM Core. - Missing Credential Helper: Without a configured credential helper, the Git client in WSL2 defaults to prompting for a username and password (which fails due to GitHub's deprecation of password authentication) or simply failing if a PAT isn't provided directly. It cannot retrieve the authentication tokens that Windows Git uses.
- GitHub PATs: GitHub mandates the use of Personal Access Tokens (PATs) for programmatic access over HTTPS, deprecating password-based authentication. The challenge is securely managing these PATs across the Windows/WSL2 boundary.
Step-by-Step Resolution
The most robust and recommended solution is to configure your Git client within WSL2 Ubuntu to leverage the Git Credential Manager Core (GCM Core) installed on your Windows host. This allows you to centralize your Git credentials, managed securely by Windows, even when operating from your Linux environment.
1. Ensure Git Credential Manager Core (GCM Core) is Installed on Windows
GCM Core is typically installed automatically when you install Git for Windows. You can verify its presence:
- Open PowerShell or Command Prompt on Windows.
- Type
git credential-manager-core version. If it's installed, you'll see its version number. - Ensure your Windows Git is configured to use GCM Core. Open Git Bash (or Command Prompt) on Windows and run:
This should already be the default for modern Git for Windows installations.git config --global credential.helper manager-core
2. Configure Git in WSL2 Ubuntu to Use Windows' GCM Core
This is the critical step where you instruct your WSL2 Git client to call the Windows GCM Core executable.
Open your WSL2 Ubuntu terminal.
Configure Git to use the Windows-installed GCM Core. The executable path can vary slightly based on your Git for Windows installation. A common path is
/mnt/c/Program Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exeor/mnt/c/Program Files/Git/cmd/git-credential-manager.exe. Let's use the most common reliable path forgit-credential-manager-core.exe.# Option A: If GCM Core is in the common mingw64/libexec path git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe" # Option B: If GCM Core is exposed directly in Git's cmd directory (common for newer GCM installations) # Use this if Option A fails. Check your Windows Git installation for the correct path. # git config --global credential.helper "/mnt/c/Program\ Files/Git/cmd/git-credential-manager.exe"- The path
Program Filesneeds to be escaped with a backslash if it contains spaces (e.g.,Program\ Files). - Double-check the exact path to
git-credential-manager-core.exeorgit-credential-manager.exeon your Windows system. You can find it by navigating toC:Program FilesGitand searching for these executables. Adjust the/mnt/c/...path accordingly. - Ensure the executable has appropriate permissions. If you encounter "Permission denied" errors, it might be due to file permissions or Windows Defender. However, calling a Windows executable from WSL2 generally works without explicit
chmodif it's already executable on Windows.
- The path
3. Perform an Initial Authentication (if necessary)
The first time you interact with GitHub from WSL2 after configuring GCM Core, it might prompt you for authentication, or a browser window might pop up from Windows to complete the OAuth flow.
- Attempt to clone a private repository:
git clone https://github.com/my-org/my-private-repo.git - If GCM Core is configured correctly, one of the following will happen:
- A Windows pop-up will appear asking you to authenticate with GitHub (e.g., using your browser, or existing Windows credentials). Follow the prompts to complete the authentication.
- If you've previously authenticated via GCM Core on Windows, it might just succeed without any prompts.
Once authenticated, GCM Core will store the token securely in the Windows Credential Manager, and your WSL2 Git client will be able to retrieve it for future operations.
4. (Alternative) Using an SSH Key
For developers who prefer SSH for Git operations, setting up an SSH key pair within WSL2 is a robust alternative.
Generate an SSH key pair within WSL2:
ssh-keygen -t ed25519 -C "[email protected]" # Follow prompts, use a strong passphrase.This will create
id_ed25519(private key) andid_ed25519.pub(public key) in~/.ssh/.Add your public key to GitHub:
- Copy the content of your public key:
cat ~/.ssh/id_ed25519.pub - Go to GitHub -> Settings -> SSH and GPG keys -> New SSH key. Paste the copied public key.
- Copy the content of your public key:
Configure SSH agent (optional, but recommended for passphrase-protected keys):
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519To make
ssh-agentpersistent across WSL2 sessions, you might need to addeval "$(ssh-agent -s)"andssh-addto your~/.bashrcor~/.zshrc. Be aware of potential issues with multiplessh-agentinstances if not handled carefully.Configure Git to use SSH for GitHub: If you're cloning an existing repository that uses HTTPS, you'll need to change its remote URL to use SSH.
cd my-private-repo git remote set-url origin [email protected]:my-org/my-private-repo.gitFor new clones, use the SSH URL directly:
git clone [email protected]:my-org/my-private-repo.git
5. (Less Recommended) Direct Personal Access Token (PAT)
While not recommended for general use due to security implications, you can directly use a PAT if other methods fail or for quick, temporary access.
Generate a Personal Access Token (PAT) on GitHub:
- Go to GitHub -> Settings -> Developer settings -> Personal access tokens -> Tokens (classic) -> Generate new token.
- Give it a descriptive name (e.g., "WSL2-Temp-Access").
- Grant it the necessary scopes (at minimum
repofor cloning/pushing). - Copy the generated token immediately; you won't see it again.
Use the PAT when prompted for a password: When you run
git cloneorgit pulland are prompted for a password, paste the PAT instead of your GitHub password.Username for 'https://github.com': <your-github-username> Password for 'https://[email protected]': <paste_your_PAT_here>Storing PATs directly in your shell history or as plain text is highly insecure. This method is only suitable for very temporary use cases where a PAT's lifespan is extremely short, or if you immediately revoke it after use. For persistent access, GCM Core or SSH keys are vastly superior in terms of security.
By following these steps, you should successfully resolve the "GitHub Actions checkout action repository authentication failed" symptom within your WSL2 Ubuntu environment, enabling seamless interaction with your private Git repositories.
Our Production Verification Guarantee
Encountering a bug not covered here or running a non-standard kernel configuration? Our solutions are continually refined against real production incidents. Submit an environment trace for our editorial team to replicate.