Vous êtes sur la page 1sur 3

SCP Usage

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]

from-host Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command user Is the user which have the right to access the file and directory, that is supposed to be copied in the case of the from-host, and the user who has the rights to write in the to-host source-file Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory destination-file Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to keep its names

SCP Options
-p Preserves the modification and access times, as well as the permissions of the source-file in the destination-file -q Do not display the progress bar -r Recursive, so it copies the contents of the source-file (directory in this case) recursively -v Displays debugging messages

SCP Examples
scp *.txt user@remote.server.com:/home/user/

That is going to copy all files with .txt extension to the folder /home/user in the remote.server.com host
scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/

That is going to recursively copy all files from Miguels home directory on 10.1.2.2 to his home folder in 10.1.2.3 host. As have been told before, scp copies files between computers using ssh, and there are three types of usage: Copy files from a local computer to a remote computer

scp somefile username@server:/home/username/

Copy files from a remote server to your local computer


scp username@server:/home/username/file_name /home/local-username/file-name

Copy files from a remote server to another remote computer This is really interesting and very useful, as the files copied from one server to the other, are not going to pass through your computer. The traffic is going to pass from one server to the other directly.
scp user_name1@server1:/home/user_name1/file_name user_name2@server2:/home/user_name2/

SCP Tricks
Bandwidth limit You may limit the bandwidth used by scp command
scp -l limit username@server:/home/uername/* .

Where limit is specified in Kbit/s. Increase scp 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. You can also increase security while decreasing speed. Everything has its cost.
scp -c 3des user@server:/home/user/file .

That is maybe the slowest, but also maybe the more secure one (I may be wrong, Im not an expert in encryption).

Final notes
It is very important to consider that scp encrypts the data before sending it over the internet. So, if you can use it over ftp or rcp, you better use it. Finally, as I said before, you can use WinSCP to copy to and from Windows to Linux or Mac. For the Mac OS Xscp is supported by default, just like with Linux.

Vous aimerez peut-être aussi