ssh-agent: keys lost after reboot / passphrase asked every time macOS Origin: Platform & cloud Last updated 5 Nov 2026

macOS: Enter passphrase for key '/Users/me/.ssh/id_ed25519': (every time after restart)

macOS doesn't automatically reload SSH keys into the agent after a restart unless configured to use the keychain.

Exact message you may see Enter passphrase for key every time macOSssh-add -K is deprecated: use --apple-use-keychainWarning: The -K and -A flags are deprecated and have been replaced by the --apple-use-keychain and --apple-load-keychain flagsssh agent keys lost after reboot macOSThe agent has no identities.
Seen on: macOS

Meaning

Add to ~/.ssh/config: Host * with AddKeysToAgent yes, UseKeychain yes, IdentityFile ~/.ssh/id_ed25519, then run ssh-add --apple-use-keychain ~/.ssh/id_ed25519 once. On macOS 12+ -K is replaced by --apple-use-keychain.

Common causes

  • No UseKeychain yes / AddKeysToAgent yes in ssh config
  • Key added without keychain flag
  • Using Homebrew ssh that ignores UseKeychain
  • Moved the key file
  • New key without passphrase stored

⚡ Quick fix

  1. ssh-add --apple-use-keychain ~/.ssh/id_ed25519
  2. Add AddKeysToAgent yes + UseKeychain yes to ~/.ssh/config
  3. Use Apple's /usr/bin/ssh

Detailed fix by platform

macOS

  1. ssh-add -l lists loaded keys; ssh-add --apple-load-keychain reloads keychain keys

How to diagnose

  1. Config — UseKeychain set?
  2. Added — With keychain flag?
  3. ssh — Apple binary?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

Bad configuration option: usekeychain — ssh: /Users/me/.ssh/config: line 5: Bad configuration option: usekeychain (macOS)Bad configuration opt…client_loop: send disconnect: Broken pipe — client_loop: send disconnect: Broken pipe (SSH session drops when idle) (Linux)client_loop: send dis…git: 'credential-osxkeychain' is not a git command — Git: git: 'credential-osxkeychain' is not a git command. See 'git --help' (macOS)git: 'credential-osxk…Homebrew Cask: It seems there is already an App at — Homebrew: Error: It seems there is already an App at '/Applications/Chrome.app' (macOS)Homebrew Cask: It see…Host key verification failed — Host key verification failed. fatal: Could not read from remote repository. (Git)Host key verification…kex_exchange_identification — kex_exchange_identification: Connection closed by remote host (Git)kex_exchange_identifi…port 22 timed out — ssh: connect to host github.com port 22: Connection timed out (Git)port 22 timed outpublickey — Git: Permission denied (publickey). fatal: Could not read from remote repository. (Git)publickeyssh-agent…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.