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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. fprintd-verify: command not found
  2. /var/cache/yum Constantly Filling Files System in CentOS/RHEL
  3. “su: Authentication failure” – in Docker
  4. foreman Command Examples in Linux
  5. Beginners Guide to Automounting File Systems in CentOS / RHEL
  6. pvcreate Command Examples in Linux
  7. How to mount USB flash drive in Linux
  8. “error: Bind to port 2222 on 0.0.0.0 failed: Permission denied” – error while starting sshd service on CentOS/RHEL
  9. gnome-calculator: command not found
  10. Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright