I would like to know an easy way to use scp to copy files and folders that are present in different paths on my file system. The ssh destination server requests a password and I
If you can express all the names of the files you want to copy from the remote system using a single glob pattern, then you can do this in a single scp
command. This usage will only support a single destination folder on the local system for all files though. For example:
scp 'RemoteHost:/tmp/[abc]*/*.tar.gz' .
copies all of the files from the remote system which are names (something).tar.gz
and which are located in subdirectories of /tmp
whose names begin with a
, b
, or c
. The single quotes are to protect the glob pattern from being interpreted from the shell on the local system.
If you cannot express all the files you want to copy as a single glob pattern and you still want the copy to be done using a single command (and a single SSH connection which will ask for your passsword only once) then you can either:
scp
, like sftp
or rsync
, or