Search code examples
bashkubernetesscp

What is the target path of scp /localdir/ root@ubuntu:?


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

Solution

  • 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.