1

Note: My question is very similar to
File location if target path not specified with scp command
But that question is asking what the target of this is:

scp -r /localdir/ root@ubuntu

My question is asking what the target of this is:

scp -r /localdir/ root@ubuntu:

Also if anyone's curious I found this syntax on the following webpage:
https://kubernetes.io/docs/setup/independent/high-availability/#copy-required-files-to-the-correct-locations

It's a Bash Script:

USER=ubuntu # customizable
CONTROL_PLANE_IPS="10.0.0.7 10.0.0.8"
for host in ${CONTROL_PLANE_IPS}; do
    scp /etc/kubernetes/pki/ca.crt "${USER}"@$host:
    scp /etc/kubernetes/pki/ca.key "${USER}"@$host:
    scp /etc/kubernetes/pki/sa.key "${USER}"@$host:
    scp /etc/kubernetes/pki/sa.pub "${USER}"@$host:
    scp /etc/kubernetes/pki/front-proxy-ca.crt "${USER}"@$host:
    scp /etc/kubernetes/pki/front-proxy-ca.key "${USER}"@$host:
done
neoakris
  • 4,217
  • 1
  • 30
  • 32
  • `scp` without a remote path is simply `cp /localdir/ .` (which will probably draw an error for a missing filename) Run as `scp -v /localdir/ root@ubuntu` to confirm. – David C. Rankin Sep 23 '18 at 02:47
  • I'm doubtful that the kubernetes official documentation would be wrong though. I'm trying to test it out with debian pods, but I'm getting scp port 22 refused after I installed openssh-server. Going to try making 2 linux VMs in a sec to see what such a command would do. – neoakris Sep 23 '18 at 03:00
  • 1
    Unless you include a `-r`, the `/localdir/` will be omitted entirely. – David C. Rankin Sep 23 '18 at 03:04
  • Thanks for pointing out the error in my example, I'll fix it – neoakris Sep 23 '18 at 03:11

1 Answers1

3

In my test, I ran the command as follows to copy test folder from host heron01 to host heron02:

yitian@heron01:~$ scp -r test/ yitian@heron02:

And the result shows that the test folder can be found at:

yitian@heron02:~$ pwd
/home/yitian

So, the result of your question is: The target directory is the home directory of the target user you are using in the scp command. In my example, the target directory is: /home/yitian in host heron02.

Yitian Zhang
  • 314
  • 1
  • 3
  • 18
  • I found the same when I provisoned 2 linux boxes to test. I did scp ca.crt root@lanip: then ran ls on the remote box and found ca.crt in my home directory, thanks you beat me to it :) – neoakris Sep 23 '18 at 03:10