Last modified: May 31, 2006 by Kachelhoffer

SSH: to copy a file with the scp command


 1. Definition
 2. Usage
 3. Syntaxe
 4. Examples

1. Definition

The scp command allows you to copy a file or a directory (-r) from the client to a server or from a server to the client. The path of the server could be given in absolute (/home/dupont/Directory for example) or relatively from the base directory Directory. To use scp, you should know the correct paths of the directories on the remote server. Also, SSH should be installed on the two servers which should communicate to make your transfert.
BE CAREFULL: at Computing Center, you should give your password. It is not possible to make an authentification using SSH keys exchange (see To connect at Computing Center using SSH).

2. Usage

scp [-pqrvBC1246] [-F ssh_config] [-S program] [-P port] [-c cipher]
    [-i identity_file] [-l limit] [-o ssh_option] [[user@]host1:]file1
    [...] [[user@]host2:]file2

3. Syntaxe

4. Examples

> scp calvat@ccali.in2p3.fr:/afs/in2p3.fr/home/c/calvat/Readme.txt .
copy the file Readme.txt from /afs/in2p3.fr/home/c/calvat on ccali.in2p3.fr to the current local directory.
> scp -r calvat@ccali.in2p3.fr:/afs/in2p3.fr/home/c/calvat/toto .
copy the directory toto and the attached sub-directories from /afs/in2p3.fr/home/c/calvat on ccali.in2p3.fr to the current local directory.