Start ssh-agent and add your SSH key
Load your passphrase-protected SSH key into the agent so git push and ssh connect without re-typing the passphrase.
Run eval $(ssh-agent) to start the agent in your session, then ssh-add ~/.ssh/id_ed25519 and type the passphrase once.
01Command
Command
$ eval $(ssh-agent) && ssh-add ~/.ssh/id_ed2551902What it does
ssh-agent keeps decrypted private keys in memory and answers authentication challenges for ssh and git. eval $(ssh-agent) sets the environment variables your shell needs to reach it, and ssh-add then prompts for the passphrase a single time. From then on every ssh connection and git push uses the cached key. Add IdentityFile ~/.ssh/id_ed25519 to ~/.ssh/config or a desktop autostart entry so the agent is always ready.
03Risk
!Warning: The agent runs per-session — a new terminal may not inherit it; use ssh-add once SSH_AUTH_SOCK points at an existing agent. ssh-add -D removes all cached keys. Never run ssh-agent as root or share agent sockets between users (agent forwarding has the same risk).
04Undo
Undo
$ ssh-add -D && eval $(ssh-agent -k)05Sources
- ssh-agent(1) - OpenBSD manual pagesEvidence: ssh-agent holds private keys used for public key authentication; ssh-add adds keys and -D deletes all identities from the agent.
- SSH keys - ArchWikiEvidence: Documents starting ssh-agent with eval $(ssh-agent), adding keys with ssh-add, and keychain/agent forwarding for persistence.
Last verified: 2026-09-18 · Category: Security & Privacy