1

What does the program ssh-copy-id actually do under the hood? Can the steps be explained as if to a child with a good understanding of computer science?

Does it use protocols already existing in the SSH specification, or does it use "trickery" to get the key copied over (such as try to run shell commands on the target system as if it were a user)? Does the "target" SSH server need to know about ssh-copy-id before-hand, and be coded to handle it, or will it work on any implementation of SSH on any OS?

IQAndreas
  • 10,145
  • 21
  • 59
  • 79
  • It's a shell script. – wurtel Dec 22 '14 at 10:36
  • 1
    @wurtel Really? Well, that's more in my ballpark. I see you are correct, `/usr/bin/ssh-copy-id` is indeed shell and not a binary! – IQAndreas Dec 22 '14 at 10:43
  • I may end up studying the source tomorrow, and if so, answering my own question. But if anyone who knows wants to answer it before then, I would be very thankful. – IQAndreas Dec 22 '14 at 10:45

1 Answers1

0

ssh-copy-id is a script, not a C program, often written in POSIX shell. You can check:

$ file "$(command -v ssh-copy-id)"
/usr/bin/ssh-copy-id: POSIX shell script, ASCII text executable

You can read its content for more details.

In general, it will do something like:

  • Do some check with parameters, ssh-agent to get the identity file.
  • Login to remote host using ssh, do some setups, copy your public key to host then quit.
cuonglm
  • 150,973
  • 38
  • 327
  • 406