How to fix The agent has no identities. in SSH

SSHBEGINNERMEDIUMUpdated Jan 4, 2026ยท 289 views

SSH shows "The agent has no identities" when ssh-agent is running but has no keys loaded. Add your private key to the agent using ssh-add to resolve this connection issue.

Quick fix

Fixes The agent has no identities.

eval "$(ssh-agent -s)"
  1. Verify the SSH agent is running
  2. Add your SSH private key to the agent
  3. Verify the key was added successfully
  4. Fix SSH key file permissions (if needed)
ssh โ€” error
eval "$(ssh-agent -s)"
The agent has no identities.

What this error means

This error occurs when the SSH authentication agent (ssh-agent) is running on your system but does not have any private keys loaded into it. The agent is a background process that holds your SSH private keys in memory and uses them to authenticate connections without requiring you to enter passphrases repeatedly. When you try to establish an SSH connection or check the loaded keys with "ssh-add -l", the agent responds that it has no identities because no keys have been added to it yet.

Typical symptoms

  • Running "ssh-add -l" returns "The agent has no identities"
  • SSH connection attempts fail with key-based authentication
  • Cannot connect to remote servers even though keys exist locally
  • Unable to use SSH for Git operations or remote deployments

Common causes

  1. SSH private keys have not been added to the agent yet
  2. SSH agent is running but was freshly started without loaded keys
  3. Keys were removed from the agent or the agent process was restarted
  4. SSH key file paths are incorrect or keys have been moved
  5. Missing or incorrect SSH_AUTH_SOCK environment variable

How to fix "The agent has no identities."

1Verify the SSH agent is running

First, check if ssh-agent is currently running. If it is not running, start it:

bash
eval "$(ssh-agent -s)"

This command starts ssh-agent and sets the necessary environment variables (SSH_AUTH_SOCK and SSH_AGENT_PID). The eval statement is important because it executes the output in your current shell.

2Add your SSH private key to the agent

Use ssh-add to load your private key into the agent. The default key location is ~/.ssh/id_rsa:

bash
ssh-add ~/.ssh/id_rsa

If you are using a different key name (ed25519, id_dsa, etc.), specify that path:

bash
ssh-add ~/.ssh/id_ed25519

You will be prompted to enter your key's passphrase if it has one. Once entered, the key is loaded into the agent.

3Verify the key was added successfully

Confirm that your key is now loaded in the agent:

bash
ssh-add -l

This lists the fingerprints of all identities currently held by the agent. You should see your key listed with its fingerprint and key type (RSA, ED25519, etc.).

Alternatively, use -L to see full public key details:

bash
ssh-add -L
4Fix SSH key file permissions (if needed)

SSH is strict about file permissions for security. Incorrect permissions can prevent the agent from using your key. Set the correct permissions:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub

The private key (id_rsa) must be readable only by you (600). The public key can be world-readable (644). The ~/.ssh directory must be accessible only by you (700).

5Persist keys across shell sessions (optional)

By default, keys added to ssh-agent are lost when you close your terminal. To automatically load keys when you connect via SSH, add this to your ~/.ssh/config file:

bash
Host *
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa

Replace id_rsa with your actual key name if different. On macOS, you can also use the UseKeychain option to store passphrases in the system keychain:

bash
Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_rsa
6Test SSH connection

Once your key is loaded, test that authentication works:

bash
ssh -v user@hostname

The -v flag shows verbose output. Look for a line indicating "Offering public key" followed by "Authentication succeeded" or a similar message. If authentication still fails, check that your public key is added to ~/.ssh/authorized_keys on the remote server.

Advanced notes

If you have multiple keys and want to add them all at once without specifying each path individually, you can use: ssh-add ~/.ssh/* (this will skip public key files and only add private keys). For security-conscious users, you can set a lifetime for loaded keys so they are automatically removed after a period of inactivity using: ssh-add -t 3600 ~/.ssh/id_rsa (this example sets a 1-hour lifetime). On some systems, you may need to check the SSH_AUTH_SOCK environment variable is set correctly by running: echo $SSH_AUTH_SOCK. If this is empty or points to a non-existent socket, your shell session may not have the agent properly initialized. Macintosh users should note that Keychain integration (UseKeychain) only works with SSH keys that were initially added to Keychain, and the option tells the system to remember the passphrase, not to add the key to the agent.

Frequently asked questions

What does "The agent has no identities." mean?
This error occurs when the SSH authentication agent (ssh-agent) is running on your system but does not have any private keys loaded into it. The agent is a background process that holds your SSH private keys in memory and uses them to authenticate connections without requiring you to enter passphrases repeatedly. When you try to establish an SSH connection or check the loaded keys with "ssh-add -l", the agent responds that it has no identities because no keys have been added to it yet.
How do I fix "The agent has no identities."?
SSH shows "The agent has no identities" when ssh-agent is running but has no keys loaded. Add your private key to the agent using ssh-add to resolve this connection issue.
What causes "The agent has no identities."?
SSH private keys have not been added to the agent yet SSH agent is running but was freshly started without loaded keys Keys were removed from the agent or the agent process was restarted
Is the "The agent has no identities." error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading