How to copy a file from a remote server to a local machine?

The syntax for scp is:

If you are on the computer from which you want to send file to a remote computer:

scp /file/to/send username@remote:/where/to/put

Here the 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 username@remote:/file/to/send /where/to/put

scp can also send files between two remote hosts:

scp username@remote_1:/file/to/send username@remote_2:/where/to/put

So the basic syntax is:

scp username@source:/location/to/file username@destination:/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 remoteuser@remoteip:/path/  localpath 

to add ssh options:

rsync -e "ssh -P $port_value" remoteuser@remoteip:/path/  localpath

--progress and --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/

Tags:

Scp

Cp