How to Transfer Files Using SCP Command in Linux

There are many way to transfer files over the network between the linux operating system. In this post, I will show the basic syntax on how to use secure copy (SCP) command to transfer the files. SCP allows files to be transferred to, from, or between Linux or Unix hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

SCP Command in Linux

SCP Command will transfer files between linux machines over a secure and encrypted connection. But for if your server does not have SCp command, you will get the following error message :

# scp
-bash: /usr/bin/scp: No such file or directory

SCP command is part of openssh-clients package. You can install scp command with this syntax :

# yum install openssh-clients -y

Before start with SCP command example, there is the definition for every syntax that i will use :

local server1 (currently ssh) = The server1 ip (192.168.2.2) that i ssh from my notebook.

3 SCP command in linux example :

To copy from local server1 (current ssh) to a remote server2. (server1–>server2)

To copy from a remote server2 to local server1 (currently ssh). ( server2 –> server1)

To copy from a remote server2 to another remote server3. ( server2–>server3)

In the third case, the data is transferred directly between the servers; your local server1 ( currently ssh) will only tell the servers what to be transfer. Let’s have a look at the syntax of this command:

About The Author

The author of this blog is a part time blogger who is very enthusiastic about computer technology and Linux open source and has more than 8 years of experience in servicing, installing, configuring, administering Linux servers and VMware.