Is there a way to prevent a certain SSH key to be automatically added to an SSH agent while all others are automatically added?

For example, assume all my keys are protected by a passphrase. I would like that my key (A) is automatically added to an SSH agent, but not key (B). That would mean that I have to enter my passphrase for (B) whenever I use it and for (A) only the very first time of use.

Update: I'm using Fedora 33 with GNOME 3.38

  • Which OS are you using? Do you use the standard ssh-agent with its AddKeysToAgent option, or is this done by something else (Keychain or GNOME Keyring)?
    – user1686
    Jan 12, 2021 at 10:00
  • I'm using Fedora 33 with GNOME 3.38 and haven't changed the default settings so far.
    – Max Maier
    Jan 12, 2021 at 10:49

1 Answer 1


the ssh-agent from openssh will try to add all the standard paths if you invoke it without any arguments. To add specific keys, you must invoke the ssh-add command with specific arguments like for example:

ssh-add /home/jaroslav/.ssh/keys/employer-jr.rsa \
   /home/jaroslav/.ssh/keys/jaroslav@balmora.2016.rsa \
   /home/jaroslav/.ssh/keys/spectre-2018.rsa \

The standard paths include


...and so on.

I have no idea how gnome on your distro invokes the agent, for me, the best way is to launch ssh-agent and ssh-add from the profile files for the shell such as ~/.bash_profile.

I have automated this workflow to a certain degree of success, and you can consult my findings by reading these scripts:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.