Has anyone had any luck getting the ssh-copy-id script that is included with FreeBSD 10 working? When using it with the -i option to pass the identity key, I get a printf error message. ssh-copy-id -i /home/dweimer/.ssh/id_rsa dweimer at webmail.dweimer.net Password for dweimer at webmail.dweimer.local: printf: Illegal option -- Both of these systems are FreeBSD 10 systems, I took a look at /usr/src/usr.bin/ssh-copy-id/ssh-copy-id.sh, and am wondering if the -- in the mkdir line below is the culprit, or if maybe something else isn't escaped properly. sendkey() { local h="$1" local k="$2" printf "%s\n" "$k" | ssh $port -S none $options "$user$h" /bin/sh -c \'' \ set -e; \ umask 077; \ keyfile=$HOME/.ssh/authorized_keys ; \ mkdir -p -- "$HOME/.ssh/" ; \ while read alg key comment ; do \ [ -n "$key" ] || continue; \ if ! grep -sqwF "$key" "$keyfile"; then \ printf "$alg $key $comment\n" >> "$keyfile" ; \ fi ; \ done \ '\' } -- Thanks, Dean E. Weimer http://www.dweimer.net/
On 02/28/2014 1:34 pm, dweimer wrote:> Has anyone had any luck getting the ssh-copy-id script that is > included with FreeBSD 10 working? > > When using it with the -i option to pass the identity key, I get a > printf error message. > > ssh-copy-id -i /home/dweimer/.ssh/id_rsa dweimer at webmail.dweimer.net > Password for dweimer at webmail.dweimer.local: > printf: Illegal option -- > > > Both of these systems are FreeBSD 10 systems, I took a look at > /usr/src/usr.bin/ssh-copy-id/ssh-copy-id.sh, and am wondering if the > -- in the mkdir line below is the culprit, or if maybe something else > isn't escaped properly.Well it wasn't that --, I removed it on my system, same result.> sendkey() { > local h="$1" > local k="$2" > printf "%s\n" "$k" | ssh $port -S none $options "$user$h" > /bin/sh -c \'' \ > set -e; \ > umask 077; \ > keyfile=$HOME/.ssh/authorized_keys ; \ > mkdir -p -- "$HOME/.ssh/" ; \ > while read alg key comment ; do \ > [ -n "$key" ] || continue; \ > if ! grep -sqwF "$key" "$keyfile"; then \ > printf "$alg $key $comment\n" >> > "$keyfile" ; \ > fi ; \ > done \ > '\' > }-- Thanks, Dean E. Weimer http://www.dweimer.net/
I modified it like this: echo "alg $alg" echo "key $key" echo "comment $comment" printf "$alg $key $comment\n" >> "$keyfile" ; \ so I could see where printf was breaking. It's breaking on the first one -- $alg Unmatched '. key: Undefined variable. comment: Undefined variable.