DEV Community

Baraa Mohamed
Baraa Mohamed

Posted on • Edited on

2

SSH-Agent: Simplifying SSH Key Management

SSH-Agent is one of the tools in the SSH suite that simplifies managing access keys for secure server connections.

You can think of the SSH-Agent as a "bag" that holds your access keys, allowing you to access servers conveniently through other servers.

Starting the SSH-Agent

Begin by running the following command to start the SSH-Agent:

eval "$(ssh-agent -s)"
Enter fullscreen mode Exit fullscreen mode

This initializes the agent — think of it as "opening the bag."

Adding Access Keys

Next, add your access keys to the agent. Each key represents a credential for accessing different servers:

ssh-add <file1>
ssh-add <file2>
ssh-add <file3>
Enter fullscreen mode Exit fullscreen mode

This is like placing keys into your bag.

Connecting to Servers

To connect to a server using a specific access key:

ssh -v -i <access-key1> -A <server1>
Enter fullscreen mode Exit fullscreen mode
  • v: Verbose mode — displays loading steps in the terminal (optional).
  • i: Specifies the access key file for authentication.
  • A: Forwards the SSH-Agent, allowing access to additional servers without re-entering keys.

Accessing Additional Servers

If you need to SSH from server1 to server2, simply run:

ssh -v -i <access-key2> <server2>
Enter fullscreen mode Exit fullscreen mode

Add the -A flag only if you plan to SSH further from server2.


Best Practices

  • Use ssh-add to securely load private keys into the agent.
  • Forward the SSH-Agent (A) only when necessary to minimize security risks.
  • Regularly clean up your agent by running ssh-add -D to remove all keys after your session.

Conclusion

By using SSH-Agent, you can simplify secure server access while reducing repetitive key management tasks.

🤍 I'd love to connect with you on LinkedIn—let's grow our network and share ideas! here

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay