Written by Guillermo Garron .
Date: 2012-04-25 16:59:35 -0400
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
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.
You can use
scp on Linux, Mac and Windows (using WinSCP).
scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
- 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
- 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
- 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
- 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
- Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
- Do not display the progress bar
- Recursive, so it copies the contents of the source-file (directory in this case) recursively
- Displays debugging messages
scp *.txt email@example.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 firstname.lastname@example.org:/home/miguel/ email@example.com:/home/miguel/
That is going to recursively copy all files from Miguel’s 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/
You may limit the bandwidth used by
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.
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, I’m not an expert in encryption).
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 X
scp is supported by default, just like with Linux.
comments powered by Disqus