How to copy a file from a remote server to a local machine?
The syntax for
If you are on the computer from which you want to send file to a remote computer:
scp /file/to/send [email protected]:/where/to/put
remote can be a FQDN or an IP address.
On the other hand if you are on the computer wanting to receive file from a remote computer:
scp [email protected]:/file/to/send /where/to/put
scp can also send files between two remote hosts:
scp [email protected]_1:/file/to/send [email protected]_2:/where/to/put
So the basic syntax is:
scp [email protected]:/location/to/file [email protected]:/where/to/put
You can read
man scp to get more ideas on this.
You can use
rsync as an alternative. It is mainly for syncing files.. but you can use it for this purpose as well.
rsync -avzh --stats --progress [email protected]:/path/ localpath
to add ssh options:
rsync -e "ssh -P $port_value" [email protected]:/path/ localpath
--stats are useful for real-time display of transfer.
I think it a better option then SCP, since it skips already transferred files, which is noticeable when you're copy-ing lot of files.
scp [email protected]:/root/Jmeter/reports.jtl Downloads/