get_ssh_keys numbered keys over raw authorized_keys lines (comments and
blanks included) while remove_ssh_key popped that id from a list of key
lines only, so any comment banner shifted every id and delete-by-id
removed the wrong key — or refused the last one as "Invalid key ID".
The rewrite also hoisted all comments to the top, shifting ids again.
- both sides now index the same sequence: non-blank, non-comment lines
in file order; delete drops the line in place so comments keep their
position
- add_ssh_key dedupes on the key-data token instead of a raw substring,
and normalizes a missing trailing newline before appending so a new
key can't be glued onto the previous line
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>