SCP (Secure Copy Protocol)
SSH can be used not only for remote login but also for file transfer in a secure way. There are two protocols for transferring files with SSH – SCP (Secure Copy Protocol) and SFTP (Secure File Transfer Protocol). In this section, we'll explain SCP.
Transferring from local to remote
To transfer a file from the local computer to the remote server, the following five sets of information are needed for the SCP command.
Key file
- Private key file path on your local computer (usually, under the .ssh directory)
Source file
- Source file path on your local computer
Destination
- User name of the remote server
- IP address of the remote server
- Destination directory path on the remote server. If you want to transfer the file to the user's home directory of the remote server, you can skip this argument.
For a better understanding, please go through the following practice section.
Practice 1
Objective:
Transfer a file from the local computer to the remote server
The following are the paths of the file to be transferred and the destination directory.
- File to be transferred: ~/dir_ch7_local/sample.txt (on the local computer)
- Destination
Subscribe now for
uninterrupted access.