[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ssh-copy-id no newline bug



Ernesto Alfonso <erjoalgo@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

Attachment: signature.asc
Description: PGP signature


Reply to: