Use Your Local SSH Keys on a Remote Server with -A
Forward your ssh-agent over SSH with -A so a remote machine can authenticate to GitHub or other servers using your local keys.
Run ssh -A user@remote-server, then from that server git clone git@github.com:... works with your local key.
01Command
Command
$ ssh -A user@remote-server02What it does
ssh-agent holds your unlocked private keys locally; -A tells SSH to forward a channel to that agent, so on the remote machine any SSH authentication (git over SSH, jumping to a third host) is actually answered by your local machine — the private key never leaves it. Set ForwardAgent yes under a specific Host in ~/.ssh/config to make it the default for trusted hosts only. On the remote side, ssh-add -l should list your keys to confirm forwarding works.
03Risk
!Warning: Only forward to servers you trust: anyone with root on the forwarded host can hijack your agent socket and authenticate as you while the session is open — never forward to shared or untrusted machines.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- ssh(1) — Linux manual page (-A / ForwardAgent)Evidence: Documents -A to enable forwarding of the ssh-agent authentication agent connection to the remote host.
- Arch Wiki — SSH keys: Agent forwardingEvidence: Explains how agent forwarding lets remote hosts authenticate with your local keys and its security caveats.
Last verified: 2026-09-18 · Category: Security & Privacy