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.

LinuxsshauthkeysMedium risk
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-server

02What 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

RiskMedium risk
Requirementsssh-agent running locally with keys added (ssh-add); no extra packages on the server
!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

Last verified: 2026-09-18 · Category: Security & Privacy