ssh-copy-id no newline bug

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

 



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:

# Assuming that the remote host treats ~/.ssh/authorized_keys as one
might expect
    populate_new_ids 0
    [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
		umask 077 ;
		mkdir -p .ssh && \
echo >> .ssh/authorized_keys && \
cat >> .ssh/authorized_keys || exit 1 ;
		if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh
.ssh/authorized_keys ; fi" \
      || exit 1
    ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l)
    ;;
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



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

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux