Study Notes on Secure Copy Protocol (SCP) and SFTP
Introduction to Secure Copy Protocol (SCP)
SCP is a command used for securely copying files over a network.
It is part of the SSH (Secure Shell) suite, which ensures secure data transfer.
SCP requires that SSH is enabled on the target server to operate.
Basic SCP Command Structure
The general syntax for using SCP is as follows:
scp [source file(s)] [user]@[remote server]:[destination path]Example:
scp file1 file2 student@remote_server:/home/studentThis command copies
file1andfile2to the specified path on the remote server as the userstudent.
Recursive Copying with SCP
To copy entire directories, the
-roption is used:Syntax:
scp -r [user]@[remote server]:[source directory] [destination path]Example:
scp -r root@remote_server:/tmp/files_to .This command copies the entire contents of the directory
TMP/files_tofrom the remote server as the userroot.
Secure File Transfer using SFTP
SFTP (SSH File Transfer Protocol) can also be used for transferring files securely.
Example process for using SFTP to transfer a file:
Initiate the SFTP session using:
sftp file3 student@192.168.29.143:/dmb/This command attempts to connect to the remote server using SFTP to copy
file3.
Upon connection, a prompt will display requesting verification of the remote host's identity. Type
yesto proceed.Enter the appropriate password for authentication.
After successful login, the file transfer takes place.
Conclusion
SCP and SFTP are powerful tools in the SSH toolkit designed to facilitate secure file transfer over potentially insecure networks.
Ensure that SSH is enabled on the target server for functionality.
Use SCP for straightforward file copying and SFTP for a more interactive file transfer experience with directory support.