Adding ssh keys may break `authorized_keys`
Adding an ssh key via ssh keys add $key
can break the format of the authorized_keys
file, depending on the state it was in before. In case it breaks, this prevents ssh access to the initrd using some or all of the ssh keys, making the system unavailable barring a manual rescue operation.
Details: the routine that adds a new ssh key, adds the given string to the authorized_keys
file, appending a newline. In particular it doesn't prepend a newline, instead assuming that the file already ended in a newline. If that assumption fails, the last ssh key that was already present gets concatenated with the new one on a single line, breaking both of them. As long as keys are added via the cryptops system this doesn't happen, but the initial authorized_keys
file might not have the trailing newline.
This should be fixed by adding the extra newline if necessary – or perhaps always: empty lines are allowed in authorized_keys
.