TrumanWong

ssh-add

Add private key to ssh-agent's cache

Supplementary instructions

The ssh-add command adds a private key to the ssh-agent cache. The command location is /usr/bin/ssh-add.

grammar

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

Options

-D: Delete all keys in ssh-agent.
-d: Remove key from ssh-agent
-e pkcs11: Delete the key provided by the PKCS#11 shared library pkcs1.
-s pkcs11: Add the key provided by the PKCS#11 shared library pkcs1.
-L: Display the public key in ssh-agent
-l: Display keys in ssh-agent
-t life: Set a timeout for the loaded key. When the timeout expires, ssh-agent will automatically uninstall the key.
-X: Unlock ssh-agent
-x: Lock ssh-agent

Example

  1. Add the private key to the ssh-agent cache:
ssh-add ~/.ssh/id_dsa
  1. Delete the key from ssh-agent:
ssh-add -d ~/.ssh/id_xxx.pub
  1. View the key in ssh-agent:
ssh-add -l