Para se preceder à copia rápida de um ou mais ficheiros entre pcs via ssh temos pelo menos duas formas:

i) scp
ii) ssh directo a partir do computador para onde se vão copiar os ficheiros (ssh user@host “cat /path/file_a_copiar” > file_destino)


Copying Files with scp (link)

The OpenSSH suite of programs is one of my favourite toolkits for administration of servers on a LAN. I routinely use the scp command to copy files between systems and move stuff around as required. In effect, it replaces the old rcp command, but it much more secure as well as more convenient to use.

To copy files between two machines, say and, sit at and use the following command:

scp *

Simple as that! Assuming you are the same user id on both machines, this will copy all files in the current directory to your home directory on the destination machine, The first thing the command will do, though, is ask you for your password on the remote system – once you supply that, then you’ll see the files copied, with progress bars.

Now, if you want to copy only some files, e.g. all txt files, use a standard wildcard, like this:

scp *.txt

Suppose you want to copy them to a destination directory other than your home directory, use:

scp *.txt

Of course, you have to have write permission on the target directory.

Suppose you want to copy files from the other machine back to the one you’re on – then use this syntax:

scp*.txt .

If you have a DNS or hosts file set up, then you can (and should) use hostnames in the command, like this:

scp mail/* mailsrvr:/home/joe/mail

This will copy the contents of the mail subdirectory (of the current directory) on this machine, to the directory /home/joe/mail on the machine mailsrvr.

How Does It Work?

In general, the syntax for scp (as for cp) is:

scp [option...] source destination

where source and destination can each take the form:




The [ ] indicates something is optional. The big difference from the cp command is the use of a hostname or IP address on either the source, destination or (unusually) both. Notice that the hostname or IP address must be followed by a colon; a common mistake (I do it all the time) is to type something like:

scp fubar.zot

but the file doesn’t turn up on So what happened? Answer: you created a file called “” that contains the same thing as fubar.zot!

If you find the password prompting is a nuisance, then you can create a private/public key pair, upload the public key to the remote system, and then use the SSH agent to supply your private key automatically.