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

**Code:** `ssh-agent: keys lost after reboot / passphrase asked every time` · **Category:** macOS · **Seen on:** macOS

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/macos/ssh-agent-keys-lost-after-reboot)
