Documentation
Source:
Troubleshooting
Info
If data is copied via SSH with
scp
make sure that the target folder is available.scp
will not create the target folder automatically and therefore just abort if it is not available.
Usage
Secure Copy or scp
can be used to copy data encrypted between computers / servers over the network via SSH.
To copy data via scp
from the local machine to a remote machine the minimum prompt looks like this. To copy from a remote computer to the local computer the path definition syntax has to be switched.
scp <path_to_source_location> <user>@<remote_ip_or_url>:/<path_to_target_location>
If you want to copy via SSH and use a password as authorization without any prompt sshpass
can be used like this:
sshpass -p <password> scp <path_to_source_location> <user>@<remote_ip_or_url>:/<path_to_target_location>
A file with the password can also be used to mitigate showing the password in the promp history:
sshpass -f <path_to_pwd_file> scp <path_to_source_location> <user>@<remote_ip_or_url>:/<path_to_target_location>
To mitigate the command prompt for adding the host to the known_hosts
file the ssh-keyscan
command can be used as shown in Connect via SSH.
The scp
command also allows to use SSH clients defined in the ~/.ssh/config
file, which is explained in Connect via SSH.