---
title: SSH Agent error after restarting computer
date: '2022-08-24T00:00:00+00:00'
url: https://www.abhinav.co/ssh-agent-related-errors-after-restarting-computer
summary: Try this if you see 'The agent has no identities' error
tags:
- ssh
- ssh-agent
- restart-issues
author: Abhinav Saxena
---

# SSH Agent error after restarting computer

After restarting my computer (Macbook/OS X), I often face problems in connecting with my AWS EC2 instances via Jumphost (also called as Bastion host).

### Error
```
The agent has no identities
```

### Fix
```
ssh-add -K ~/.ssh/id_rsa
ssh-add -A
```
On latest version of OS X, you can add `UseKeychain yes` to your `~/.ssh/config`
```
Host *
  UseKeychain yes
```

### Explanation
SSH Agent holds decrypted keys in memory and doesn't write to disk. Hence, the keys must be unlocked after each restart. On OS X, ssh-add has a special flag related to Keychain. While this flag (-K) is a bit hard to find, however it works on most of the OS X versions.
