• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

ssh-add Command Examples in Linux

by admin

The ssh-add command adds private key identities to the SSH key agent. If the key is protected by a password, the user only needs to enter the password once, and the agent will automatically authenticate the user.

ssh-add has a few decent options available, some of which are handy to know about.

-l will allow you to see loaded identities, along with their fingerprints:

$ ssh-add -l
256 SHA256:P7FdkmbQQFoy37avbKBfzMpEhVUaBY0TljwYJyNxzUI vagrant@centos1 (ED25519)

-D will allow you to remove all identities (and -d can be used to remove specific ones):

$ ssh-add -D
All identities removed.

-x will lock an agent, while -X will unlock it:

$ ssh-add -l
256 SHA256:P7FdkmbQQFoy37avbKBfzMpEhVUaBY0TljwYJyNxzUI vagrant@centos1 (ED25519)
$ ssh-add -x
Enter lock password: 
Again: 
Agent locked.
$ ssh-add -l
The agent has no identities.
$ ssh-add -X
Enter lock password: 
Agent unlocked.
$ ssh-add -l
256 SHA256:P7FdkmbQQFoy37avbKBfzMpEhVUaBY0TljwYJyNxzUI vagrant@centos1 (ED25519)

ssh-add Command Examples

1. Add the default ssh keys in `~/.ssh` to the ssh-agent:

# ssh-add

2. Add a specific key to the ssh-agent:

# ssh-add path/to/private_key

3. List fingerprints of currently loaded keys:

# ssh-add -l

4. Delete a key from the ssh-agent:

# ssh-add -d path/to/private_key

5. Delete all currently loaded keys from the ssh-agent:

# ssh-add -D

6. Add a key to the ssh-agent and the keychain:

# ssh-add -K path/to/private_key

Filed Under: Linux

Some more articles you might also be interested in …

  1. Linux rsync command with practical examples
  2. “az logout” Command Examples (Log out from an Azure subscription)
  3. conntrack Command Examples in Linux
  4. Sample /etc/services file in Linux
  5. rdesktop Command Examples in Linux
  6. How to Install Cockpit’s Web Console in CentOS/RHEL 8
  7. TIME_WAIT queue troubles
  8. netplan: command not found
  9. “git format-patch” Command Examples
  10. ember: The Ember.js command-line utility

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright