ssh-copy-id no newline bug

Ernesto Alfonso erjoalgo at gmail.com
Mon Mar 21 07:48:44 AEDT 2016


I agree it would be bad to add empty lines. I came up with this function:

function is_newline_terminated	{
    test -z "$(tail -c1 "${1}")"
}

to check whether an append would corrupt the file.

Maybe something like:

is_newline_terminated ~/.ssh/authorized_keys || echo >> ~/.ssh/authorized_keys

would work in the appropriate place.



On 3/20/16, Stephen Harris <lists at spuddy.org> wrote:
> On Sun, Mar 20, 2016 at 07:30:01PM +0000, Alex Bligh wrote:
>>
>> On 20 Mar 2016, at 19:15, Philip Hands <phil at hands.com> wrote:
>>
>> > 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?
>>
>> Well it would be at least mildly annoying my previously nice looking file
>> now has a pile of blank lines in just because someone didn't know
>> how to use their editor ...
>
> You can be pretty sure it'd end up causing a bug report as well
> ("ssh-copy-id introduces blank lines into good files").
>
> --
>
> rgds
> Stephen
>


More information about the openssh-unix-dev mailing list