1

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

2
  • 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)? Jan 12, 2021 at 10:00
  • 1
    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

0

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/[email protected] \
   /home/jaroslav/.ssh/keys/spectre-2018.rsa \
   /home/jaroslav/.ssh/keys/rusty-2020-jaro-generic.ed25519

The standard paths include

~/.ssh/id_rsa
~/.ssh/id_dsa
~/.ssh/id_ed25519

...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:

https://raw.githubusercontent.com/tox2ik/agent-ssh/master/.agent-ssh

https://github.com/tox2ik/go-smux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .