Make salt-key work with key fingerprints in addition to/instead of minion ID globs
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 i think this is a sound idea. I'll add it as a feature request. Thanks
I too think it would be a great idea to allow deletion of a key with a specific fingerprint.
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?
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 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.
My process to work around this missing feature was:
- Delete both keys (one Accepted and one Denied) for the minion from the master.
- Restart the salt-minion service on the minion. Now, its new key will be listed as Unaccepted instead of Denied on the master.
- Accept the new key on the master.
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.
Fingerprints would be really helpful for me as well.
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.