ssh-add Linux Command Guide
The Linux ssh-add command is used to add private keys to the SSH authentication agent, allowing secure and convenient access to remote servers without entering passwords repeatedly. This command eliminates the need to re-enter private key passphrases every time an SSH connection is made, improving efficiency and security in managing SSH keys. By using ssh-add, users can easily add, list, and remove keys from the authentication agent, streamlining the SSH key management process.
ssh-add Syntax:
Options:
Option | Description |
---|---|
-l | Lists fingerprints of all identities |
-L | Prints public key for all identities |
-E hash | Specifies the hash algorithm for keys |
-K | Loads the default keys from macOS keychain |
-k | Prompts for passphrase and adds key |
-q | Suppresses all warnings and errors |
-s | Saves the passphrase in the keychain |
-t lifetime | Sets default cache lifetime in seconds |
-x | Locks the agent with a passphrase |
-X | Unlocks the agent |
-c | Enables confirmation for use of keys |
-d | Deletes the specified identities |
-e pkcs11 | Lists keys served by the pkcs11 |
-s reader slot | Adds a smartcard key |
-D | Deletes all identities |
-U smartcard | Removes all smartcard keys |
-u | Removes all identities from the agent |
Parameters:
Parameter | Description |
---|---|
file | Specifies an alternative to the default file path |
ssh-add Command Samples:
Add a specific private key to the SSH agent
This command adds the private key “id_rsa” to the SSH agent.
Add all private keys in the default directory to the SSH agent
This command automatically adds all private keys found in the default directory (~/.ssh) to the SSH agent.
Specify an identity file to add to the SSH agent
The command adds a specific private key file (“private_key.pem”) to the SSH agent.
Display currently added identities in the SSH agent
This command lists the fingerprints of all identities currently represented by the SSH agent.
Remove a specific key from the SSH agent
This command removes a specific private key from the SSH agent.
Remove all identities from the SSH agent
This command removes all identities from the SSH agent.
Add a key without using a passphrase
This command adds a private key to the SSH agent without prompting for a passphrase.
ssh-add FAQ:
How do I add a specific SSH key using ssh-add in Linux?
To add a specific SSH key using ssh-add in Linux, use the following command:
How do I list the keys currently added to the SSH agent with ssh-add in Linux?
To list the keys currently added to the SSH agent with ssh-add in Linux, use the following command:
How do I remove all added keys from the SSH agent using ssh-add in Linux?
To remove all added keys from the SSH agent using ssh-add in Linux, use the following command:
How do I set a specific lifetime for an added SSH key with ssh-add in Linux?
To set a specific lifetime for an added SSH key with ssh-add in Linux, use the following command:
How do I display verbose output when adding an SSH key with ssh-add in Linux?
To display verbose output when adding an SSH key with ssh-add in Linux, use the following command:
How do I add a passphrase-protected SSH key without prompting for its passphrase every time with ssh-add in Linux?
To add a passphrase-protected SSH key without prompting for its passphrase every time with ssh-add in Linux, use the following command:
Applications of the ssh-add command
- To add private keys to the SSH authentication agent
- To manage multiple private keys for SSH connections
- To enable seamless and secure authentication without password prompts
- To easily authenticate to remote servers with SSH keys