Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:ssh_copier_un_fichier_avec_la_commande_scp [2016/12/16 10:16] (current)
Line 1: Line 1:
 +Last modified: Jun 27, 2016 by Bouvet\\
 +\\
 +
 +====== SSH: to copy a file with the scp command ======
 +
 +\\
 +\\
 +
 +=====  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 [[:​ssh_se_connecter_au_centre_de_calcul|To connect at Computing Center using SSH]] ).
 +=====  Usage  =====
 +
 +<​code>​
 +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
 +</​code>​
 +=====  Syntaxe ​ =====
 +
 +
 +To copy a file from a server called //server1// to an other one called //server2// :
 +<​code>​
 +> scp Login1@Server1:​Path1/​File1 Login2@Server2:​Path2/​File2
 +</​code>​
 +  *To copy a local file from the current directory to a directory on the remote server:
 +<​code>​
 +> scp File Login@Server:​Path/​
 +</​code>​
 +To copy a local directory, with sub-directories if any, to a directory on the remote server:
 +<​code>​
 +> scp -r Directory Login@Server:​Path/​
 +</​code>​
 +  *To copy a file from the remote server to the current local directory:
 +<​code>​
 +> scp Login@Server:​Path/​File .
 +</​code>​
 +To copy a directory from the remote serveur to the current local directory:
 +<​code>​
 +> scp -r Login@Server:​Path/​Directory .
 +</​code>​
 +
 +=====  Examples ​ =====
 +
 +<​code>​
 +> scp calvat@cca.in2p3.fr:/​afs/​in2p3.fr/​home/​c/​calvat/​Readme.txt .
 +</​code>​
 +copy the file //​Readme.txt//​ from ///​afs/​in2p3.fr/​home/​c/​calvat//​ on cca.in2p3.fr to the current local directory.
 +<​code>​
 +> scp -r calvat@cca.in2p3.fr:/​afs/​in2p3.fr/​home/​c/​calvat/​toto .
 +</​code>​
 +copy the directory //toto// and the attached sub-directories from ///​afs/​in2p3.fr/​home/​c/​calvat//​ on cca.in2p3.fr to the current local directory.
 +
  
  • en/ssh_copier_un_fichier_avec_la_commande_scp.txt
  • Last modified: 2016/12/16 10:16
  • (external edit)