Using the ssh-add command, you can add the private key to the cache of the Ssh-agent to improve the SSH authentication speed. The command is in /usr/bin/ssh-add.

Command syntax

ssh-add [-cDdLlXx] [-t life] [file ...]  ssh-add -s pkcs11 ssh-add -e pkcs11Copy the code

Command options

  • -d: Deletes all keys in the ssh-agent.
  • -d: deletes the key from the ssh-agent
  • -e pkCS11: deletes the key provided by pkCS1.
  • -s pkCS11: adds the key provided by pkCS1 shared library PKCS11.
  • -l: Displays the public key of the Ssh-Agent
  • -l: displays the key in the ssh-agent
  • -t life: sets the timeout period for the loaded key. After the timeout period, the ssh-agent automatically unloads the key
  • -x: unlocks the ssh-Agent
  • -x: locks the SSH agent

Open the SSH – agent

Ssh-agent is disabled in the default operating system. You need to manually enable it

> ssh-agent bash
Copy the code

Add the private key tossh-agentIn the cache of

> ssh-add ~/.ssh/id_dsa
Copy the code

Example Delete the key from the ssh-agent

> ssh-add -d ~/.ssh/id_dsa.pub
Copy the code

View the key in the Ssh-agent

> ssh-add -l
Copy the code

Common mistakes

Could not open a connection to your authentication agent. If no, run ssh-agent bash and then run ssh-add ~/. Ssh/id_dsa

Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station