scp (Secure Copy)
The scp command allows you to securely copy files and directories between two locations, typically between a local and a remote machine, using the SSH protocol.
Common `scp` Commands
Copy a File from Local to Remote
scp /path/to/local/file.txt user@hostname:/path/to/remote/directory/Copies file.txt from your local machine to the specified directory on the remote server.
Copy a File from Remote to Local
scp user@hostname:/path/to/remote/file.txt /path/to/local/directory/Copies file.txt from the remote server to a directory on your local machine.
Copy an Entire Directory Recursively
scp -r /path/to/local/dir user@hostname:/path/to/remote/dirThe -r flag stands for "recursive" and is used to copy entire directories and their contents.
Use a Different Port
scp -P 2222 /path/to/local/file.txt user@hostname:/remote/dir/The -P (uppercase) flag allows you to specify the port number if the remote SSH server is not running on the default port 22.