Menu Close

Using SCP in Ubuntu Linux

This article talks about how to use SCP to transfer files in Ubuntu Linux.

For related subjects, please refer to the SOC Table of Contents.

 

Like the RCP command, SCP also copies files. Files or directories can be copied from your local system to a remote system, from a remote system to your local system, and between two remote systems from your local system.

The main difference between them is how SCP copies files in a more secure way, where both the files and the password are encrypted. The SCP command has the following syntax and formatting:

scp [option] [user]@[host]:[file directory] [user]@[host]:[target directory]

Where the main options are

-P        Specify the remote host ssh port.

-p        Preserves file modification and access times.

-q        Suppress the progress meter and non-error messages.

-C        Compress the data as it is being sent.

-r        Recursively copies the entire directory.

For example, if we wanted to copy a file named scptest from our local ubuntu user with IP 192.168.0.86 to the target root user with IP 192.168.0.88, we would use the following code. Nearly identical to that of the RCP command.

scp /home/ubuntu/test_folder1/scptest root@192.168.0.88:/home

If we were to reverse the process and copy the file from the host to the computer you are currently on, you would use the following. Note that these SCP commands are extremely similar to RCP. You can opt to not specify the target directory for the file to be copied to your home folder. Note that there is a “.” before specifying the target directory.

rcp root@192.168.0.88:/home/scptest ./test_folder2

Posted in Textbook and Training Project

Related Articles

Leave a Reply

Your email address will not be published.

Leave the field below empty!