misc/189246: ssh-copy-id contains a syntax error

Dan McGregor dan.mcgregor at usask.ca
Fri May 2 15:30:00 UTC 2014

>Number:         189246
>Category:       misc
>Synopsis:       ssh-copy-id contains a syntax error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 02 15:30:00 UTC 2014
>Originator:     Dan McGregor
>Release:        10.0-STABLE
FreeBSD shadrach.dyndns.org 10.0-STABLE FreeBSD 10.0-STABLE #29 r264456: Mon Apr 14 08:00:01 CST 2014     dan at shadrach.dyndns.org:/usr/obj/usr/src/sys/SHADRACH  amd64
ssh-copy-id contains a syntax error in the script it sends to the remote end. It certainly affects bash and zsh. It appears like so:

% ssh-copy-id root at beaglebone.local                                                        
zsh:12: parse error near `if'

or with bash:

% ssh-copy-id root at beaglebone.local
/bin/sh: -c: line 11: syntax error near unexpected token `if'
/bin/sh: -c: line 11: `         if [ -x /sbin/restorecon ]; then \'

The tested versions were zsh version 5.0.5 and bash version 4.3.0
Have a remote machine with either bash or zsh as /bin/sh
The attached patch fixes it.

Patch attached with submission follows:

Index: usr.bin/ssh-copy-id/ssh-copy-id.sh
--- usr.bin/ssh-copy-id/ssh-copy-id.sh	(révision 265225)
+++ usr.bin/ssh-copy-id/ssh-copy-id.sh	(copie de travail)
@@ -45,7 +45,7 @@
 			if ! grep -sqwF "$key" "$keyfile"; then \
 				printf "$alg $key $comment\n" >> "$keyfile" ; \
 			fi ; \
-		done \
+		done ; \
 		if [ -x /sbin/restorecon ]; then \
 			/sbin/restorecon -F "$HOME/.ssh/" "$keyfile" >/dev/null 2>&1 || true ; \


More information about the freebsd-bugs mailing list