# Make macOS remember your SSH keys after restart

> On macOS, with each reboot, you suddenly can't connect to your servers as all your keys are purged from the ssh agent. There's a fix for that.

- URL: https://graffino.com/til/macos-keeps-forgetting-your-ssh-keys-after-restart
- Author: Zeno Popovici
- Channel: command-line
- Published: 2020-08-11
- Updated: 2024-07-25

### We need to tell macOS to add the keys to the agent, in order to make them persistent after reboot.


We have to create new file in `~/.ssh/` called `config`
```bash
vi ~/.ssh/config
```

with the following content:

```bash
Host *
   AddKeysToAgent yes
   UseKeychain yes   
```

Then, we need to add our keys to the agent and macOS keychain (so your private key password is remembered).

```bash
ssh-add -D
ssh-add -K ~/.ssh/*
```

To verify that our keys are present in the agent: 
```bash
ssh-add -l
```
