📜  scp - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:47:18.760000             🧑  作者: Mango

SCP - Securely Transfer Files Between Machines

SCP (Secure Copy) is a command-line utility in Unix and Linux systems that allows you to securely transfer files between machines. It uses SSH (Secure Shell) protocol to encrypt the data being transferred and ensure secure communication between machines.

Basic Usage

The syntax of SCP is similar to the syntax of the cp command used to copy files locally.

scp [options] [source] [destination]

Here, source specifies the file or directory to be copied, and destination specifies the location where the file or directory should be copied to.

Options
  • -P option specifies the port number on which the remote machine is running the SSH server.
  • -r option is used when copying a directory and its contents along with all subdirectories recursively.
  • -q option suppresses the progress meter and warning messages.
  • -p option preserves the modification times, access times, and modes of the original file or directory.
Examples
  1. Copy a file from local machine to a remote machine:
scp /path/to/local/file username@remote:/path/to/destination/folder
  1. Copy a file from a remote machine to local machine:
scp username@remote:/path/to/remote/file /path/to/destination/folder
  1. Copy a directory from local machine to a remote machine:
scp -r /path/to/local/directory/ username@remote:/path/to/destination/folder
  1. Copy a directory from a remote machine to local machine:
scp -r username@remote:/path/to/remote/directory/ /path/to/destination/folder
Conclusion

SCP is a reliable and secure way to transfer files between machines. It allows you to transfer files and directories from one machine to another quickly and easily. The encryption provided by SSH ensures that your data remains private and secure during the transfer.