• 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 not found

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)

If you encounter the below error while running the ssh-add command:

ssh-add: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
OS X brew install openssh
Debian apt-get install openssh-client
Ubuntu apt-get install openssh-client
Alpine apk add openssh
Arch Linux pacman -S openssh
Kali Linux apt-get install openssh-client
CentOS yum install openssh-clients
Fedora dnf install openssh-clients
Raspbian apt-get install openssh-client

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. Understanding the /etc/fstab file in Linux
  2. Swapon Fails To Mount Swap – Gives Invalid Argument Error
  3. How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)
  4. CentOS / RHEL 7 : How to Change the machine-id
  5. How to uninstall fail2ban on Ubuntu
  6. lastlog: command not found
  7. Understanding How an Email System Works
  8. How to format code within web pages
  9. find WWN Number of HBA Card in Redhat Linux and CentOS
  10. Beginners Guide to Linux Software Management with RPM

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