Copy files from one server to another server.

@mit $ingh. May 09, 2015 Comments

Linux (SCP)

Introduction SCP

scp stands for secure cp (copy), which means you can copy files across ssh connection. That connection will be securely encrypted, it is a very secure way to copy files between computers.

scp uses by default the port 22, and connect via an encrypted connection or secure shell connection. (ssh for short)

You can use scp to copy files from or to a remote server. You can also copy files from one remote server to another remote server, without passing traffic through your PC.



Copy single file from local to a remote destination

scp /path/to/example.txt user@host:/path/to/destination-folder/


Copy single file from a remote server to your current local server

scp user@host:/path/to/example.txt /path/to/destination-folder


Copy single file from a remote server to another remote server

scp user1@server1:/path/to/example.txt user2@server2:/path/to/folder/


Copy single file from a remote host to the same remote host in another location



Copy multiple files with one command

scp file1.txt file2.txt file3.txt

If the files are in different folders, just specify the complete path.

scp /path/dir1/file1.txt /path/dir2/file2.txt /path/dir3/file3.txt


Copy all files of a specific type from local to remote server

scp /path/to/folder/*.ext user@server:/path/to/folder/


Copy all files in a folder from local to a remote server

scp /path/to/folder/* user@server:/path/to/folder/


Copy all files in a folder recursively from local to a remote server

scp -r /home/user/html/*


Copy a folder and all its contents from local to a remote server

scp -r /path/to/source-folder user@server:/path/to/destination-folder/


We have seen the basic uses scp, now we will see some special uses and tricks of this great command

Increase Speed

scp uses AES-128 to encrypt data, this is very secure, but also a litle bit slow. If you need more speed and still have security, you can use Blowfish or RC4.

To increase scp speed change chipher from the default AES-128 to Blowfish

scp -c blowfish user@server:/home/user/file .

Or use RC4 which seems to be the fastest

scp -c arcfour user@server:/home/user/file .

This last one is not very secure, and it may not be used if security is really an issue for you.


Increase Security

If security is what you want, you can increase it, you will lose some speed though.

scp -c 3des user@server:/home/user/file .


Limit Bandwidth

You may limit the bandwidth used by scp command

scp -l limit username@server:/home/uername/* .

Where limit is specified in Kbit/s. So for example, if you want to limit speed at 50 Kbps

scp -l50 user@server:/path/to/file /path/to/folder


Save Bandwidth

Yoy can save bandwidth by enabling compression, let's see our example with compression.

scp -C user@server:/path/to/file /path/to/folder


Use IPv4 or IPv6

If you want to force the use of either IPv4 or IPv6 use any of these ones.

scp -4 user@server:/path/to/file /path/to/folder

The above one is for IPv4, and below for IPv6.

scp -6 user@server:/path/to/file /path/to/folder


Specify a port

If the remote server does not have ssh listening on default 22 port, you can make scp to use the port where the remote server is listening to:

scp -P [port] [user]@[server]:[path/to/]file [/path/to/]file

Using the capital letter P you can make scp to use a port other than 22 which is the default for ssh. Let's say your remote server is listening on 2222.

scp -P 2222 user@server:/home/jane/file /home/jane/


Use verbose output

If you want to see what is happening under the hood, use the -v parameter for a verbose output

scp -v user@server:/home/jane/file /home/jane/



Windows (PSCP)
If you are working on a Windows powered computer, you can still enjoy this by using pscp command in your command prompt.

Introduction PSCP

pscp is a shell command that works almost on Windows Shell almost the same way that scp works on Linux or Mac OS X, you first need to download it from this page.

1. Install pscp.exe in your local system by (put the pscp.exe in C:\Windows\ OR put it anywhere and add the path to environment variable).
2. Open command prompt and run the below commands for copy files to one server to another server.

PSCP Options:
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-P port connect to specified port
-pw passw login with specified password

Copying files from your UNIX host(remote server) to your Windows PC.

pscp user@host:/home/user/public_html/ "C:\Users\amit\Desktop\destination-folder"


Copying files from your Windows PC to our UNIX host.

pscp "C:\Users\amit\Desktop\example.txt" user@host:/home/user/public_html


  • server
  • scp
  • pscp
  • download