Im trying to copy a public key to the ~/.ssh/authorized_keys file on a Solaris server. It fails with this error message:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub <USER>@<HOST>
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "~/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
<USER>@<HOST>'s password: <PASSWORD>
sh: test: argument expected

Seems like this is a problem with Solaris default tcsh shell. Is there a way to either make this work or make ssh-copy-id use bash?

  • Can you tell if the sh: test: argument expected error message is generated locally or from the remote server? – Andrew Henle Jun 6 '18 at 14:20
  • 2
    How would I figure that out? – gmolau Jun 6 '18 at 17:02

tcsh is by no means the "default" shell for SunOS/Solaris.

/bin/sh is the default shell for Solaris 10 and down. /bin/bash is the default shell for Solaris 11 forward.

The script will work properly with /bin/ksh if you remove the "local" command from in front of several variable inits.

  • Can you expand on what you mean by "remove the "local" command from in front of several variable inits"? – alphabetasoup Mar 4 '19 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.