Bug 1530

Summary: ssh-copy-id: strip colon from end of hostname
Product: Portable OpenSSH Reporter: Colin Watson <cjwatson>
Component: MiscellaneousAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: trivial CC: djm, dtucker
Priority: P2    
Version: 5.1p1   
Hardware: Other   
OS: Linux   
URL: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226172
Bug Depends on:    
Bug Blocks: 1708    
Attachments:
Description Flags
strip colon from end of hostname
none
openssh-ssh-copy-id.patch djm: ok+

Description Colin Watson 2008-10-09 22:59:35 AEDT
Created attachment 1573 [details]
strip colon from end of hostname

When using ssh-copy-id, people often suffix the hostname with a colon, by subconscious analogy with scp. It would be nice to make this silently work. The attached patch does this.
Comment 1 Damien Miller 2008-12-08 09:57:22 AEDT
Is the substitution "${1%:}" supported in the standard Bourne shell?
Comment 2 Colin Watson 2008-12-08 10:37:22 AEDT
It's not a bashism at any rate, being in POSIX (http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02).

I suspect that it is unfortunately not portable to Solaris' anaemic shell. I usually program to POSIX shell where I can, but if ssh-copy-id needs to work on Solaris then I concede that that might be a problem and that it'll need to use command substitution and sed instead.
Comment 3 Darren Tucker 2010-08-03 16:12:48 AEST
You're right, solaris' /bin/sh doesn't support it:

# a=foo:
# echo ${a%:}
bad substitution
# uname -rs
SunOS 5.8

This, although uglier, works:
host=`echo $1 | sed 's/:$//':`
Comment 4 Darren Tucker 2010-08-03 16:21:15 AEST
Created attachment 1909 [details]
openssh-ssh-copy-id.patch

Strip trailing colon from hostname.
Comment 5 Darren Tucker 2010-08-03 16:22:31 AEST
BTW solaris' /bin/sh doesn't do tilde expansion either, so it'll not work as a target right now.
Comment 6 Darren Tucker 2010-08-10 13:37:09 AEST
applied, will be in the 5.6p1 release.

Thanks.
Comment 7 Darren Tucker 2010-08-27 10:28:12 AEST
With the release of OpenSSH 5.6p1 this bug is now considered closed.  If you have further problems please reopen or file a new bug as appropriate.