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 user@host:/remote/destination/folder

Upload directories

scp -r /local/source user@host:/remote/destination

Download a file

scp user@host:/file/to/download.txt /local/destination

Download an entire directory

scp -r user@host:/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.