« Back to SSH: Frequently Asked Questions

How to add a SSH key to the SSH agent

How to add a SSH key to the SSH agent?

Use the ssh-add command and provide the relevant SSH key to add it to the SSH agent.

ssh-add ~/.ssh/id_ed25519

When the SSH agent is running, the ssh-add command can be used to load a SSH key. The SSH agent then will request a password when needed, and load the key details in memory.

Adding the SSH key just requires the path to the private key.

ssh-add ~/.ssh/id_ed25519

When the key is loaded, use the -l or -L option to show the identities that the SSH agent has.

ssh-add -l

Errors

Could not open a connection to your authentication agent

Most likely your SSH agent is not running. Check if the process is running. If not, start the agent:

eval $(ssh-agent)

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also a cheat sheet available.

  • eval
  • ssh

Other questions related to SSH

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon