salt icon indicating copy to clipboard operation
salt copied to clipboard

Make salt-key work with key fingerprints in addition to/instead of minion ID globs

Open anlutro opened this issue 10 years ago • 9 comments

In the case where you have 2 salt keys for the same minion ID - maybe it was re-provisioned with a different minion key and you forgot to delete the old one - you're going to end up with this salt-key -F output:

Accepted Keys:
example_minion_id 00:1c:14:19:cc:47:95:e0:63:f3:af:...
Denied Keys:
example_minion_id d5:19:b1:86:52:f4:06:28:f4:01:b6:...

However, there's no way to just delete the accepted key so that you can accept the denied key instead. If you do salt-key -d example_minion_id it'll ask you if you want to delete both keys.

I ended up having to manually rm the key I wanted to remove. If there was a way to make salt-key operations work on fingerprints in addition to/instead of minion ID globs, that would be great.

anlutro avatar Jun 10 '16 10:06 anlutro

@anlutro i think this is a sound idea. I'll add it as a feature request. Thanks

Ch3LL avatar Jun 10 '16 23:06 Ch3LL

I too think it would be a great idea to allow deletion of a key with a specific fingerprint.

kpostrup avatar Aug 22 '16 13:08 kpostrup

I'd definitely want to get this in if somebody were to write it. @anlutro or @kpostrup do you both know where the code in question lives?

cachedout avatar Sep 11 '16 23:09 cachedout

What is the status of this? old servers (rebuilt) are occasionally polluting our masters. Would be useful to be able to deny/block servers based on keys/regex, not just minon_ids.

i.e.

$ salt-key -d example_minion_id -k 'd5:10.*'
Warning you will delete example_minion_id (d5:19:b1:86:52:f4:06:28:f4:01:b6:...) [Yn] y
example_minion_id (d5:19:b1:86:52:f4:06:28:f4:01:b6:...) deleted.

$ salt-key -L
Accepted:
example_minion_id 00:1c:14:19:cc:47:95:e0:63:f3:af:...

oc avatar May 02 '17 12:05 oc

@oc this is not currently on our immediate roadmap due to other higher critical bugs/issues. Feel free to take an attempt at it though. Without glancing at the code i'm guessing it might be in salt/key.py where the logic is.

Ch3LL avatar May 02 '17 16:05 Ch3LL

My process to work around this missing feature was:

  1. Delete both keys (one Accepted and one Denied) for the minion from the master.
  2. Restart the salt-minion service on the minion. Now, its new key will be listed as Unaccepted instead of Denied on the master.
  3. Accept the new key on the master.

nhavens avatar Feb 06 '18 23:02 nhavens

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar May 22 '19 23:05 stale[bot]

Fingerprints would be really helpful for me as well.

adevuyst avatar May 21 '20 13:05 adevuyst

This also seems useful from a security perspective: rather than accepting a key based on manual inspection (or piping through grep, or something), salt-key taking a fingerprint would allow copying the fingerprint from the minion to the master, and having salt-key on the master responsible for verifying that the key is actually as expected.

dehnert avatar Nov 22 '20 03:11 dehnert