This guide covers how to forward authentication agents (GPG and SSH) from your host machine to the VM, enabling secure operations like commit signing and private repository access.
Agent forwarding allows you to use your host machine's authentication credentials inside the VM without copying private keys. This provides:
- Security: Private keys never leave your host machine
- Convenience: Seamless authentication for git operations, signing, and SSH connections
- Consistency: Same authentication setup across host and VM
Enable GPG signing in the VM by forwarding your GPG agent from the host machine.
Configure GPG support during template creation:
# Setup with GPG support
claude-vm setup --gpg
# Or enable in config fileAdd to .claude-vm.toml:
[tools]
gpg = trueWhen GPG forwarding is enabled:
- Forwards your GPG agent socket to the VM
- Syncs your public keys to the VM
- Enables git commit signing inside the VM
- Works automatically on every session
Once enabled, you can use GPG operations transparently:
# Sign commits (uses your host GPG key)
git commit -S -m "Signed commit"
# Sign files
gpg --sign document.txt
# List available keys (shows keys from host)
gpg --list-keysProblem: GPG signing fails with "No secret key" error
Solution: Ensure GPG agent is running on host:
# On host machine
gpg-agent --daemonProblem: Public keys not available in VM
Solution: Re-run setup to sync keys:
claude-vm setup --gpgForward your SSH agent for git operations over SSH and remote server access.
SSH agent forwarding is available on-demand using the -A flag. No template configuration needed.
Enable SSH agent forwarding at runtime:
# Run with SSH agent forwarding
claude-vm -A shell
# Or with run command
claude-vm -A "git push"
# Works with any command
claude-vm -A "ssh user@remote-server"SSH agent forwarding is useful for:
- Private repositories: Push/pull from private repositories over SSH
- Remote servers: SSH to remote servers for deployment or management
- Git operations: Any git operation requiring SSH authentication
- SSH keys: Operations requiring SSH key authentication
SSH agent forwarding uses native SSH agent forwarding (ssh -A). This means:
- Your private keys never leave the host machine
- The VM can only use keys for authentication, not extract them
- Standard SSH agent protocol is used for maximum compatibility
While SSH agent forwarding is generally safe, be aware:
- Only forward to trusted VMs (claude-vm VMs are isolated and disposable)
- The VM can use your keys while the session is active
- Keys cannot be extracted or copied from the VM
Configure git identity and commit signing in the VM from your host configuration.
Enable git configuration during template creation:
# Setup with git support
claude-vm setup --git
# Or enable in config fileAdd to .claude-vm.toml:
[tools]
git = trueWhen git configuration is enabled:
- Copies your git
user.nameanduser.emailfrom host to VM - Automatically configures commit signing if enabled on host
- Detects GPG or SSH signing configuration
- Provides contextual warnings about signing requirements
If you have commit signing enabled on your host, you need to enable the appropriate forwarding:
GPG signing: Enable both git and gpg capabilities
claude-vm setup --git --gpgThis configures git identity and forwards GPG agent for signing.
SSH signing: Enable git capability and forward SSH agent at runtime
# Setup
claude-vm setup --git
# Run with SSH agent forwarding
claude-vm -A "make a commit"This configures git identity and uses SSH agent forwarding for signing.
Once configured, git operations use your host identity:
# Your git identity is automatically configured
git config user.name # Shows your host name
git config user.email # Shows your host email
# Signed commits work with proper agent forwarding
git commit -m "My commit" # Automatically signed if configuredFor git configuration to work:
- Git must be configured on host:
git config --global user.nameanduser.email - For GPG signing: Enable
gpgcapability in template - For SSH signing: Use
-Aflag to forward SSH agent at runtime
Problem: Git identity not configured in VM
Solution: Check host configuration:
# On host machine
git config --global user.name
git config --global user.emailIf not set, configure on host first, then re-run setup.
Problem: Signed commits fail with GPG
Solution: Ensure both git and gpg capabilities are enabled:
claude-vm setup --git --gpgProblem: Signed commits fail with SSH
Solution: Use -A flag when running commands that need signing:
claude-vm -A "git commit -m 'message'"You can use multiple types of agent forwarding together:
# Setup template with git and GPG support
claude-vm setup --git --gpg
# Run with SSH agent forwarding for remote operations
claude-vm -A "git push origin main"This enables:
- Git identity configuration (from git capability)
- GPG signing for commits (from gpg capability)
- SSH authentication for push/pull (from -A flag)
- Enable what you need: Only enable agent forwarding for the operations you need
- Use git capability for identity: Always enable
gitcapability if you're working with git repositories - GPG for signing: Use GPG forwarding if you sign commits with GPG keys
- SSH for remote access: Use
-Aflag when you need to access remote servers or private repositories - Test in VM: After setup, test operations in VM shell to ensure everything works:
claude-vm shell
# In VM:
git config --list
gpg --list-keys
ssh -T git@github.comAgent forwarding is designed to be secure, but keep these points in mind:
- VM isolation: Claude-vm VMs are ephemeral and isolated, making them safe for agent forwarding
- Private keys stay on host: Neither GPG nor SSH forwarding ever exposes your private keys to the VM
- Temporary access: Forwarded agents are only available during the VM session
- Audit trail: All operations using forwarded agents are logged on the host
- Trust boundary: Only forward agents to VMs you control and trust