SCP (or secure copy) is a widely available and simple-to-use command-line utility that allows you to copy files and directories between two locations securely. It relies on ssh
, so when you have ssh access to any server you can easily upload/download files to/from this server.
Uploading files
scp file-to-upload.txt [email protected]:/target/remote/directory
Downloading files
scp [email protected]:/target/remote/directory/file-to-download.txt ./
Flags and options
-P
- specifies the remote host ssh port when it's different than 22;
-p
- preserves files modification and access times;
-q
- use this option if you want to suppress the progress meter and non-error messages;
-C
- this option forces scp to compress the data as it is sent to the destination machine.
-r
- This option tells scp to copy directories recursively (yes, you can copy directories also).
Also, you can use -i
flag to specify a key file for the ssh connection:
scp -i /path/to/id_rsa file-to-upload.txt [email protected]:/target/remote/directory