Technology and General Blog

This tutorial clarifies how to fetch files and directories from a remote host to our local gadget.

SCP or Protected Copy Protocol is an SSH-primarily based protocol that allows sharing of information in between remote gadgets. Making use of SCP, you can ship a receive file from and to a local gadget or involving remote products.

Currently, SCP is regarded outdated, and it has been changed by SFTP and RSYNC. At the finish of the SCP directions, I extra strategies to down load documents from distant hosts applying SFTP with a very similar syntax as SCP.

Duplicate or Download a File From Distant to Area Employing SCP

SCP syntax is quite very simple. Just invoke SCP adopted by the distant username, @, the IP tackle or host, colon, and the route to the file. If not specified, the default path is the distant user’s dwelling listing. Then, define the area path exactly where the file will be saved regionally.

The scp command was intended to be equivalent to the cp command. The file copy’s area is specified at the stop of the command.

A straightforward scp instance to duplicate a remote file to the regional device would be:

scp @:  

In my circumstance, I will copy the file named linuxhint from the remote unit The linuxhint file is stored on the kali user’s residence listing, the consumer I will authenticate. Consequently soon after the colon, I never specify the route, which is the residence directory by default, and I just type the filename (“linuxhint”). Then, I specify the present directory as the community area to store the file by typing a dot:

scp [email protected]:linuxhint .

As you can see, the linuxhint file was copied into the current community listing.

In the subsequent example, I obtain the file named linuxhint2 from the distant system to the /residence/linuxhint/locdir listing. The linuxhint2 file is saved in the dir directory named within just the distant consumer (kali) property listing:

scp [email protected]:dir/linuxhint2 /house/linuxhint/locdir/

Duplicate or Obtain a Directory Recursively Utilizing SCP

To down load or copy directories from remote to community making use of SCP, you will need to employ the -r (recursively) flag.

With the exception of the -r flag extra as shown in the pursuing example, the syntax to obtain directories is the same as downloading files from remote to area devices:

scp -r [email protected]:dir/ /root/

As you can see, the directory named dir was downloaded with all its content material.

Add a File or Directory From Nearby to Remote Using SCP

The preceding section of this tutorial stated how to fetch or down load data files from a distant machine employing SCP. This segment of the tutorial points out how to add or send a file to a remote gadget.

The case in point down below demonstrates how to deliver or drive a file named linuxhintfile to the distant device’s default directory or the user’s dwelling. The big difference with receiving information is you need to determine the file to deliver or its path just right after invoking SCP, as shown in the following screenshot.

scp linuxhintfile [email protected]:

Don’t forget, the scp command was made to preserve the cp command syntax. Thus, the file location listing is normally specified at the finish of the command, the two when sending or fetching information.

Defining directories is the identical as when acquiring or downloading information. The instance below emphasised how to send out the file named file2 and stored it under the linuxhint person property directory. The file will be saved in the remote device’s dir subdirectory, found in the default household listing.

scp /residence/linuxhint/file2 [email protected]:dir/

To deliver directories to apply a similar syntax, just increase the -r flag to send out data files recursively, as proven in the image below. The linuxhintdir directory is despatched to the remote device’s /tmp listing:

Fetch or Download Documents and Directories Applying SFTP

Downloading documents utilizing SCP is an out of date process changed largely by SFTP (Secure File Transference Protocol). The present appropriate means to transfer files are SFTP or RSYNC. SFTP can be used in interactive manner, but this section demonstrates how to use it with a comparable syntax as SCP.

In the case in point below, The sftp command is used to download the file named linuxhint from the remote host to the area /tmp directory.

sftp [email protected]:linuxhint /tmp

Fetching directories recursively working with SFTP requires the -r flag, just like when applying the scp command, as shown in the screenshot beneath. The linuxhintdir directory is downloaded to the regional /tmp directory.

sftp -r [email protected]:linuxhintdir /tmp

As you can see, the directory was downloaded recursively.

The SFTP command is primarily employed in its interactive mode, which is deeply discussed in this tutorial. Also, think about utilizing the rsync command, another up-to-date and secure substitute to the out-of-date scp command.


Downloading documents from a distant host to a nearby machine working with SCP is probably the major choice for most Linux users, together with technique directors. As you can see scp is a basic command, almost as easy to use as the cp command. We always assumed it is protected given that its identify claims it is secure. However, it is no for a longer time protected, and it was flagged as deprecated by its developers.

The key alternative, the Secure File Transference Protocol or SFTP protocol, isn’t so person-welcoming as the scp command in its interactive mode. That’s one of the reasons driving the scp command popularity even soon after currently being deprecated. However, customers need to take into consideration adopting SFTP or RSYNC as the principal possibilities.

Thank you for looking at this tutorial, maintain following Linux Hint for further Linux suggestions and tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *