Saturday, January 22, 2022

Linux: SCP Command to Securely Transfer Files


SCP (secure copy) is a command-line utility that allows you to securely copy files and directories between two locations.

With scp, you can copy a file or directory:

  • From your local system to a remote system.
  • From a remote system to your local system.
  • Between two remote systems from your local system.

It uses the same authentication and security as it is used in the Secure Shell (SSH) protocol

 

Before you Begin

The scp command relies on ssh for data transfer, so it requires an ssh key or password to authenticate on the remote systems.

The colon (:) is how scp distinguish between local and remote locations.

To be able to copy files, you must have at least read permissions on the source file and write permission on the target system.

Be careful when copying files that share the same name and location on both systems, scp will overwrite files without warning.

 

Copying Local File to Remote System:

scp [source_file_path_LOCAL] [user]@[Destination_Host_IP]:[destination_file_path_REMOTE]

scp C:\Prabhat\fileName.xls prabhatk@10.10.0.2:/tmp/

 

Copying Remote File to Local System: 

scp [user]@[Destination_Host_IP]:[source_file_path_REMOTE] [destination_file_path_LOCAL]

scp prabhatk@10.10.0.2:/tmp/ fileName.xls C:\Prabhat\

 

Note: These commands need to be executed from Local System to perform above operation.

 

 

 

Resources:

·         https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/ 

·         https://www.geeksforgeeks.org/scp-command-in-linux-with-examples/   

 

No comments:

Post a Comment

Popular Posts

Most Featured Post

GitHub: Squash all commits in PR

  Command Meaning git fetch origin Get the latest origin/master . git reset --soft origin/master Move your branch to match origin/master , b...