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

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

You can read man scp to get more ideas on this.

Point to be Noted

  • scp -r will copy recursively
  • Use scp -P 123 to specify a custom port
  • You should hit this command from local, not from the server

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@/file/to/send /where/to/put

--progress and --stats are useful for real-time display of transfer.


 

Some Examples:

scp root@10.240.179.4:/root/Jmeter/reports.jtl Downloads/

scp sadananad@ipaddress:/home/demo/public_html/myproject.tar.gz .

scp -P2233 sadananad@ipaddress:/home/demo/public_html/myproject.tar.gz .

scp -r root@178.62.54.83:~/folderinremoteuserdir ~/folderinlocaluserdir

rsync -avzh --stats --progress remoteuser@remoteip localpath

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