ssh-copy-id no newline bug

Philip Hands phil at hands.com
Mon Mar 21 06:15:31 AEDT 2016


Ernesto Alfonso <erjoalgo at gmail.com> writes:

> When editing ~/.ssh/authorized_keys manually, sometimes users forget
> to add a newline at the end of the file, causing the next ssh-copy-id
> call to append a new key to an existing key, invalidating both keys.
>
> This can be fixed by simply adding a newline before appending the key.
>
> Something like this change to
> openssh-source/openssh-6.7p1/contrib/ssh-copy-id might work:

This seems like it should do no harm (given that sshd(8) declares that
blank lines are ignored as comments), although I'd instead do it by
adding a \n to the printf, thus:

  [ "$DRY_RUN" ] || printf '\n%s\n' "$NEW_IDS" | ssh ...

Is anyone going to be upset by the resulting blank lines being added by
ssh-copy-id when the file was not missing a terminating newline?

Cheers, Phil.
-- 
|)|  Philip Hands  [+44 (0)20 8530 9560]  HANDS.COM Ltd.
|-|  http://www.hands.com/    http://ftp.uk.debian.org/
|(|  Hugo-Klemm-Strasse 34,   21075 Hamburg,    GERMANY
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20160320/6504489a/attachment-0001.bin>


More information about the openssh-unix-dev mailing list