Help: Command Line File Transfer

SCP Commands:

The typical format for using scp is as follows:

      $ scp [options] [username@host1.domain:][filename or directory] [username@host2.domain:][filename or directory]

The command can be shortend a bit by not needing to specifically list the local host as in the following cases:

To move a file from your local computer to another computer, you can use the following format:

      $ scp [options] localfile.extension [username@host2.domain:][directory]

To move a file from the other computer to your local computer, you can use the following format:

      $ scp [options] [username@host2.domain:][directory] [localdir]

However, to transfer a file on one machine to another while working on yet another machine, use the typical format:

      $ scp [options] [username@host1.domain:][filename or directory] [username@host2.domain:][filename or directory]

WARNING: Be careful when transfering files with same names as overwriting may occur!


Options:

-c  
    Selects the cipher to use for encrypting the data transfer. 

-i  
    Selects the file from which the identity (private key) for RSA authentication is 
    read. 

-p  
    Preserves modification times, access times, and modes from the original file. 

-r  
    Recursively copy entire directories. 

-v  
    Verbose mode. Causes scp and ssh to print debugging messages about their progress.
    This is helpful in debugging connection, authentication, and configuration problems. 

-B  
    Selects batch mode (prevents asking for passwords or passphrases). 

-q  
    Disables the progress meter. 

-C  
    Compression enable. Passes the -C flag to ssh to enable compression. 

-P  
    Specifies the port to connect to on the remote host. Note that this option is written 
    with a capital `P' because -p is already reserved for preserving the times and modes 
    of the file in rcp. 

-4  
    Forces scp to use IPv4 addresses only. 

-6  
    Forces scp to use IPv6 addresses only.


Examples:

Typical file transfer from my local computer to another computer:

      $ scp paulinm@fang.cs.sunyit.edu:HelloWorld.txt paulinm@spunky.cs.sunyit.edu:HelloWorldDir

Shortend format for transfering a local file to another computer:

      $ scp HelloWorld.txt paulinm@spunky.cs.sunyit.edu:HelloWorldDir

Shortend format for transfering a directory on another computer to a local directory:

      $ scp -r paulinm@spunky.cs.sunyit.edu:HelloWorldDir HelloWorldLocal

Using the typical format for transfer a file from computer 1 to computer 2 while you are on computer 3:

      $ scp paulinm@fang.cs.sunyit.edu:HelloWorld.txt paulinm@spunky.cs.sunyit.edu:HelloWorldDir

Using a wildcard to transfer multiple files:

      $ scp h*.text paulinm@spunky.cs.sunyit.edu:HelloWorldDir