To copy files or folders using the scp
command in Linux:
- Transferring a File from Local to Remote
Specify the file’s location on your local system, the remote system’s username, address, and the destination path on the remote system. - Transferring a File from Remote to Local
Indicate the file’s location on the remote system, along with its username and address, and the target path on your local machine. - Copying a Folder
Use a recursive option to include all files and subdirectories when copying a folder. You can transfer folders in either direction (local to remote or remote to local). - Custom Options
You can specify:- A custom SSH port if the remote server doesn’t use the default.
- Compression for faster transfers.
- A specific private key for authentication if needed.
- Authentication and Permissions
Ensure SSH is configured on the remote system. You’ll be prompted for the password unless you’ve set up key-based authentication.
This method works over a secure connection, making it reliable for transferring data.