command line, linux

Copying files with SCP

Whenever you want to upload some files to your server and do it securely, use SCP (which stands for “secure copy protocol”). The transfer is done on top of SSH, which ensures secure connection.

Upload a file

scp file.txt [email protected]:/remote/destination/folder

Upload directories

scp -r /local/source [email protected]:/remote/destination

Download a file

scp [email protected]:/file/to/download.txt /local/destination

Download an entire directory

scp -r [email protected]:/remote/source /local/destination

Additional options you may need

-P port-number -i path-to-private-key

In case of getting Permission denied error, ascertained above data is correct, you may be trying to save file to folder which belongs to different user. Make sure given user has rights to write files in destination folder.