ssh-copy-id: Issue with target machine with non-sh shell

Lukas Stabe lukas at stabe.de
Tue Dec 24 14:28:56 EST 2013


Hi!

I have the following issue with ssh-copy-id:

The login-shell of the user I am trying to copy my keys to is fish. fish does not
behave very sh-y. For example it does not support `command || alternative`, which
makes it choke on the following part of the script (lines 273 ff):

    ssh "$@" "
      umask 077 ;
      mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
      if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi”

There is a very simple solution to this, which would make the code more robust in 
general: execute the code on the target machine in a `/bin/sh -c '<code>’` call,
like this:

    ssh "$@“ “/bin/sh -c '
      umask 077 ;
      mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
      if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi’”

Please consider adding this to ssh-copy-id :)

Best regards,
Lukas Stabe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20131224/dae16ff2/attachment-0001.bin>


More information about the openssh-unix-dev mailing list