Once I've ssh'd into my remote server, what would the command be to copy all files from a directory to a local directory on my machine?
Copy a single file locally If you want to copy a file from one location to another within your system, you can do so by typing rsync followed by the source file name and the destination directory. Note: Instead of “/home/tin/file1. txt”, we can also type “file1” as we are currently working in the home directory.
Rsync (Remote Sync) is the most commonly used command for copying and synchronizing files and directories remotely as well as locally in Linux/Unix systems.
Short answer – You can't. rsync can't use ftp as a remote host. So rsync does not work over ftp session/protocol.
From your local machine:
rsync -chavzP --stats [email protected]:/path/to/copy /path/to/local/storage
From your local machine with a non standard ssh port:
rsync -chavzP -e "ssh -p $portNumber" [email protected]:/path/to/copy /local/path
Or from the remote host, assuming you really want to work this way and your local machine is listening on SSH:
rsync -chavzP --stats /path/to/copy [email protected]:/path/to/local/storage
See man rsync
for an explanation of my usual switches.
If you have SSH access, you don't need to SSH first and then copy, just use Secure Copy (SCP) from the destination.
scp user@host:/path/file /localpath/file
Wild card characters are supported, so
scp user@host:/path/folder/* /localpath/folder
will copy all of the remote files in that folder.If copying more then one directory.
note -r will copy all sub-folders and content too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With