State ssh_auth.absent does not remove keys is type or options are present in key "name"
Given that there is no example for ssh_auth.absent in the documentation, a Salt state writer might write the following state to remove a key by copying a key "name" that was previously specified in a ssh_auth.present state:
sshkeys:
ssh_auth:
- absent
- user: root
- comment: removing user@email from authorized keys
- names:
- ssh-rsa AAAAB3Nza[...]== user@mail
However, Salt will falsely return that the key is not present. This is because the absent function uses:
# Get just the key
name = name.split(' ')[0]
https://github.com/saltstack/salt/blob/fbfd926fdd0c7686b6be4da1dbfe4e9e18bbea60/salt/states/ssh_auth.py#L272
For the above example, the ssh_auth.absent state will incorrectly check for the key "ssh-rsa" using the ssh.check_key module.
I've verified that the remove key operation works properly if the "ssh-rsa" prefix is omitted in the example above.
Good call. We should make sure present and absent take the same inputs so you can copy and paste. (That's the problem, right? Copying and pasting?)
Copy and pasting from a present state was what caught this issue for us. However, pasting a key in from a .pub file could have triggered this issue as well.
Ah, gotcha. Thanks.
Fixed with PR #9030