|
scp.exe
SCP is a secure copy of files using the ssh server as a gateway to encrypt the files. The files are copied through a Secure Shell session launched by the scp client. The scp client launches a ssh session to the server, which launches the scp server. A machine must have the scp client, plus the ssh client to initiate a secure copy. The remote machine must have a scp client, plus a ssh daemon to respond to a scp request. The destination file will retain the file attributes of the source file. The copy can be configured to retain the source file date or use the copy time stamp.
The same scp program is used by both the client and server, therefor the console scp client is installed with both our ssh server and client
The syntax to copy files using scp is:
scp user@source:drive:\directory\file user@destination:drive\directory\file
The local username and machine are not required, but the destination file name is required. For example, to copy the file foo.txt located in the temp directory on drive d: to the remote machine temp directory on drive c, use
scp d:\temp\foo.txt username@remote_machine:c:\temp\foo.txt
The reverse can be used, if you are copying from the remote machine.
scp username@remote_machine:c:\temp\foo.txt d:\temp\foo.txt
Usage
scp [-1246qQaprvBCL] [-S path-to-ssh] [-o ssh-options] [-P port] [-c cipher] [-i identity] [-A password] f1 f2
or
scp [options] file1 ... filen [directory]
Options
The scp client accepts the following command line options, which are displayed if you enter scp without options on the command line.
|
1
|
force the ssh1 protocol
|
|
2
|
force the ssh2 protocol
|
|
4
|
force IPV4 addresses
|
|
6
|
force IPV6 addresses
|
|
B
|
process a batch file
|
|
p
|
preserve the original file date
|
|
r
|
recursively copy all files in the directory and all subdirectories
|
|
v
|
verbose mode - display debug information
|
|
C compression level
|
What compression level should be used. This is the same as the -C option for the ssh client
|
|
o ssh-options
|
Options that should be passed to the ssh client. Options that are allowed are defined in the config file of the ssh client. See SSH Configuration File for more info.
Special note that there should not be any space between the o and the option.
The o option can be used as often as necessary to pass all the desired ssh options.
|
|
P
|
server side port number
|
|
c cipher
|
Cipher algorithm to use. This is the same as the -c option for the ssh client.
|
|
a
|
Turn on statistics display for each file
|
|
A
|
pass a password on the command line
|
|
q
|
Turn off statistics display.
|
|
Q
|
Turn on statistics display.
|
|
i identity
|
Use the user identity instead of the interactive user. This is the same as the -i option for the ssh client.
|
|
L
|
use privileged port
|
Return Codes
The scp client has a return code of either 0 (zero) for successful file transfer or 1 (one) for failed transfer. This error code can be obtained by checking the errorlevel variable, such as "echo %errorlevel%" after the file transfer. If multiple files are transferred, the error code will be success if all files transferred successfully.
Examples
The most common scp file transfer involves using a key for authentication. To pass a key for authentication use the -o option:
scp -oidentityFile2=key_name source_file user@server:destination_path/destination_file_name
SCP on a different port can also be done with the -o option:
scp -oport=portNumber source_file user@server:destination_path/destination_file_name
|