How to fix error: gpg failed to sign the data: gpg: problem with the agent: No pinentry in Git

GitINTERMEDIATEMEDIUMUpdated Dec 6, 2025· 243 views

The 'gpg failed to sign the data' error with 'No pinentry' occurs when GPG cannot find or access the pinentry program needed to prompt for your passphrase. This typically happens after system updates, in SSH sessions, or when the GPG agent configuration is missing or incorrect.

Quick fix

Fixes error: gpg failed to sign the data: gpg: problem with the agent: No pinentry

# Find pinentry binaries
which pinentry pinentry-tty pinentry-curses pinentry-mac pinentry-gnome3 2>/dev/null

# On Linux, check common locations
ls -la /usr/bin/pinentry* 2>/dev/null

# On macOS with Homebrew
ls -la $(brew --prefix)/bin/pinentry* 2>/dev/null
  1. Verify pinentry is installed
  2. Configure GPG agent with pinentry path
  3. Restart the GPG agent
  4. Set GPG_TTY for terminal sessions
git — error
# Find pinentry binaries
which pinentry pinentry-tty pinentry-curses pinentry-mac pinentry-gnome3 2>/dev/null
# On Linux, check common locations
ls -la /usr/bin/pinentry* 2>/dev/null
# On macOS with Homebrew
ls -la $(brew --prefix)/bin/pinentry* 2>/dev/null
error: gpg failed to sign the data: gpg: problem with the agent: No pinentry

What this error means

The "gpg failed to sign the data" error with "problem with the agent: No pinentry" indicates that GPG's agent cannot locate or launch the pinentry program. Pinentry is a helper application that securely prompts you for your GPG key passphrase—without it, GPG cannot unlock your private key to create signatures. When you run a Git command that requires signing (like `git commit -S` or when `commit.gpgsign` is enabled), Git invokes GPG to sign the data. GPG then contacts the gpg-agent, which needs to ask for your passphrase. The agent delegates this to a pinentry program, but if pinentry is missing, misconfigured, or incompatible with your current environment (such as a headless SSH session), the signing process fails. This error is common after OS upgrades, when switching between GUI and terminal sessions, in CI/CD pipelines, or when using remote connections where no display is available for graphical passphrase prompts.

Typical symptoms

  • Git commits fail with 'error: gpg failed to sign the data' and 'No pinentry'
  • Error occurs immediately when attempting to sign a commit or tag
  • Signing worked previously but stopped after a system update or upgrade
  • Error appears when committing via SSH but not in local GUI terminal
  • CI/CD pipelines fail at commit signing step
  • Running 'echo test | gpg --clearsign' produces the same pinentry error
  • Error happens after installing or updating GPG/GnuPG
  • The issue appears in WSL but not in Windows Git Bash

Common causes

  1. Pinentry program is not installed on the system (most common)
  2. GPG agent configuration file is missing the pinentry-program path
  3. Configured pinentry path is incorrect or points to non-existent binary
  4. Using a GUI pinentry in a headless/SSH environment with no display
  5. GPG agent was not restarted after configuration changes
  6. System update changed pinentry location or removed it
  7. Multiple GPG installations with conflicting configurations
  8. WSL2 or container environment without proper TTY configuration

How to fix "error: gpg failed to sign the data: gpg: problem with the agent: No pinentry"

1Verify pinentry is installed

First, check if a pinentry program exists on your system:

bash
# Find pinentry binaries
which pinentry pinentry-tty pinentry-curses pinentry-mac pinentry-gnome3 2>/dev/null

# On Linux, check common locations
ls -la /usr/bin/pinentry* 2>/dev/null

# On macOS with Homebrew
ls -la $(brew --prefix)/bin/pinentry* 2>/dev/null

If no pinentry is found, you need to install one:

On Ubuntu/Debian:

bash
sudo apt update
sudo apt install pinentry-tty
# Or for GUI: sudo apt install pinentry-gnome3

On Fedora/RHEL/CentOS:

bash
sudo dnf install pinentry
# Or: sudo yum install pinentry

On macOS:

bash
brew install pinentry-mac
# Or for CLI: brew install pinentry

On Arch Linux:

bash
sudo pacman -S pinentry
2Configure GPG agent with pinentry path

Create or update the GPG agent configuration file:

bash
# Create the .gnupg directory if it doesn't exist
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg

# Find your pinentry path
PINENTRY_PATH=$(which pinentry-tty || which pinentry || which pinentry-curses)
echo "Pinentry found at: $PINENTRY_PATH"

# Add to gpg-agent.conf
echo "pinentry-program $PINENTRY_PATH" >> ~/.gnupg/gpg-agent.conf

For macOS with pinentry-mac:

bash
echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf

For Linux GUI environments:

bash
# GNOME
echo "pinentry-program /usr/bin/pinentry-gnome3" >> ~/.gnupg/gpg-agent.conf

# KDE
echo "pinentry-program /usr/bin/pinentry-qt" >> ~/.gnupg/gpg-agent.conf

View your configuration:

bash
cat ~/.gnupg/gpg-agent.conf
3Restart the GPG agent

After configuration changes, restart the GPG agent:

bash
# Kill the existing agent
gpgconf --kill gpg-agent

# Or use pkill
pkill gpg-agent

# The agent will restart automatically on next GPG use
# Or start it manually:
gpg-agent --daemon

Verify the agent is running with the new configuration:

bash
gpgconf --list-components
gpg-agent --version
4Set GPG_TTY for terminal sessions

For terminal-based pinentry to work, GPG needs to know which terminal to use:

bash
# Set GPG_TTY for current session
export GPG_TTY=$(tty)

# Add to your shell profile for persistence
echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
# Or for zsh:
echo 'export GPG_TTY=$(tty)' >> ~/.zshrc

# Reload your profile
source ~/.bashrc  # or source ~/.zshrc

This is especially important for:
- SSH sessions
- Terminal multiplexers (tmux, screen)
- WSL environments
- Headless servers

5Test GPG signing

Verify that signing now works:

bash
# Test GPG signing directly
echo "test" | gpg --clearsign

# You should see output like:
# -----BEGIN PGP SIGNED MESSAGE-----
# Hash: SHA256
#
# test
# -----BEGIN PGP SIGNATURE-----
# ...
# -----END PGP SIGNATURE-----

If this works, test Git signing:

bash
# Create a test signed commit
git commit --allow-empty -S -m "Test signed commit"

# Verify the signature
git log --show-signature -1
6Use loopback pinentry mode (alternative)

If standard pinentry doesn't work (common in CI/CD or Docker), use loopback mode:

bash
# Add to ~/.gnupg/gpg.conf
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf

# Add to ~/.gnupg/gpg-agent.conf
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf

# Restart agent
gpgconf --kill gpg-agent

With loopback mode, GPG will prompt for the passphrase directly in the terminal instead of using a separate pinentry program.

Note: This is less secure than using a proper pinentry program, but useful for automated environments.

7Fix for SSH sessions without display

When connecting via SSH, GUI pinentry programs fail because there's no display:

bash
# Use TTY-based pinentry for SSH sessions
# In ~/.gnupg/gpg-agent.conf:
pinentry-program /usr/bin/pinentry-tty

# Or use curses-based for better interface:
pinentry-program /usr/bin/pinentry-curses

You can also configure conditional pinentry selection in your shell profile:

bash
# Add to ~/.bashrc or ~/.zshrc
if [[ -n "$SSH_CONNECTION" ]]; then
  export GPG_TTY=$(tty)
  # Optionally update agent config for TTY pinentry
fi

After making changes:

bash
gpgconf --kill gpg-agent
8macOS-specific fix with pinentry-mac

On macOS, the recommended solution is using pinentry-mac which integrates with Keychain:

bash
# Install pinentry-mac
brew install pinentry-mac

# Configure GPG to use it
echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" > ~/.gnupg/gpg-agent.conf

# Restart the agent
gpgconf --kill gpg-agent

# Test
echo "test" | gpg --clearsign

If you previously had GPG Suite installed and it was updated or removed:

bash
# Reinstall GPG Suite
brew reinstall --cask gpg-suite

# Or use standalone GPG
brew reinstall gnupg pinentry-mac

Note: pinentry-mac allows saving your passphrase in macOS Keychain, reducing passphrase prompts.

9WSL2-specific configuration

Windows Subsystem for Linux requires additional configuration:

bash
# Install pinentry
sudo apt install pinentry-tty

# Configure GPG agent
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg

cat > ~/.gnupg/gpg-agent.conf << 'EOF'
pinentry-program /usr/bin/pinentry-tty
allow-loopback-pinentry
EOF

cat > ~/.gnupg/gpg.conf << 'EOF'
use-agent
pinentry-mode loopback
EOF

# Set permissions
chmod 600 ~/.gnupg/*

# Add to ~/.bashrc
echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
source ~/.bashrc

# Restart agent
gpgconf --kill gpg-agent

For WSL2, the loopback pinentry mode often works best since there's no native display forwarding.

10Verify configuration and debug

If issues persist, debug the GPG configuration:

bash
# Check GPG configuration
gpgconf --list-dirs
gpgconf --list-options gpg-agent

# Verify agent socket exists
ls -la $(gpgconf --list-dirs agent-socket)

# Test agent connection
gpg-connect-agent /bye

# Enable verbose output for Git
GIT_TRACE=1 git commit --allow-empty -S -m "Debug test"

# Check GPG directly with verbose output
echo "test" | gpg --verbose --clearsign

Common issues to look for:
- Socket permission problems
- Multiple GPG installations conflicting
- Incorrect home directory permissions

Advanced notes

### Understanding Pinentry

Pinentry is a collection of passphrase dialog programs. Different variants exist for different environments:

| Program | Environment | Notes |
|---------|-------------|-------|
| pinentry-tty | Basic terminal | Works everywhere, minimal interface |
| pinentry-curses | Terminal | Better UI with ncurses |
| pinentry-gnome3 | GNOME | Native GTK3 dialogs |
| pinentry-qt | KDE | Native Qt dialogs |
| pinentry-mac | macOS | Keychain integration |

### Cache Passphrase to Reduce Prompts

Configure the agent to cache your passphrase:

bash
# In ~/.gnupg/gpg-agent.conf
default-cache-ttl 3600      # Cache for 1 hour
max-cache-ttl 86400         # Maximum cache of 24 hours

Restart agent after changes: gpgconf --kill gpg-agent

### Multiple Pinentry Programs

You can use update-alternatives on Linux to switch between pinentry programs:

bash
# View available pinentry options
sudo update-alternatives --config pinentry

# Set pinentry-tty as default
sudo update-alternatives --set pinentry /usr/bin/pinentry-tty

### CI/CD Pipeline Configuration

For automated environments without interactive prompts:

bash
# Import key non-interactively
echo "$GPG_PRIVATE_KEY" | gpg --batch --import

# Sign commits using cached passphrase or preset passphrase
gpg --batch --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" ...

Or configure Git to use a specific GPG with preset passphrase handling.

### Docker Container Setup

For signing commits in Docker:

dockerfile
RUN apt-get update && apt-get install -y gnupg pinentry-tty

# Copy GPG configuration
COPY .gnupg/gpg.conf /root/.gnupg/
COPY .gnupg/gpg-agent.conf /root/.gnupg/

# Set permissions
RUN chmod 700 /root/.gnupg && chmod 600 /root/.gnupg/*

### Temporarily Disable Signing

If you need to commit urgently while troubleshooting:

bash
# Single commit without signing
git commit --no-gpg-sign -m "message"

# Disable signing temporarily
git config --global commit.gpgsign false

# Re-enable when fixed
git config --global commit.gpgsign true

### Socket Issues

If the agent socket has permission issues:

bash
# Remove stale socket
rm -f $(gpgconf --list-dirs agent-socket)

# Restart agent
gpgconf --kill gpg-agent
gpg-agent --daemon

### Debugging Agent Communication

bash
# Check agent status
gpg-connect-agent 'getinfo version' /bye

# List cached keys
gpg-connect-agent 'keyinfo --list' /bye

# Reload agent configuration
gpg-connect-agent reloadagent /bye

Frequently asked questions

What does "error: gpg failed to sign the data: gpg: problem with the agent: No pi" mean?
The "gpg failed to sign the data" error with "problem with the agent: No pinentry" indicates that GPG's agent cannot locate or launch the pinentry program. Pinentry is a helper application that securely prompts you for your GPG key passphrase—without it, GPG cannot unlock your private key to create signatures. gpgsign is enabled), Git invokes GPG to sign the data.
How do I fix "error: gpg failed to sign the data: gpg: problem with the agent: No pi"?
The 'gpg failed to sign the data' error with 'No pinentry' occurs when GPG cannot find or access the pinentry program needed to prompt for your passphrase. This typically happens after system updates, in SSH sessions, or when the GPG agent configuration is missing or incorrect.
What causes "error: gpg failed to sign the data: gpg: problem with the agent: No pi"?
Pinentry program is not installed on the system (most common) GPG agent configuration file is missing the pinentry-program path Configured pinentry path is incorrect or points to non-existent binary
Is the "error: gpg failed to sign the data: gpg: problem with the agent: No pi" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading