Advanced copy of the linux copy command scp command

  • 2020-05-09 19:44:23
  • OfStack

Linux command scp

scp -- secure copy (remote file copy program): she is a secure remote file copy program.

SYNOPSIS: the syntax is as follows
scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program]

[[user@]host1:]file1 ... [[user@]host2:]file2

See the above various parameters, options, you see it. But it doesn't matter. Let's break it up into pieces and analyze it one by one.
In fact, this command is similar to the cp 10-point command we usually use.

The simplest use of scp is scp [[user@]host1:]file1... [[user@]host2:]file2, do you understand?
For example, I need to copy the Linux file /home/oracle/*.tar file from the Linux host /home/oracle/* on 192.168.1.2 to the Linux host /home/siebel file on 192.168.1.3.
scp oracle@192.168.1.2:/home/oracle/*.tar   siebel@192.168.1.3:/siebel/
Enter the above command, enter the newline to confirm, may let you enter the password, according to the prompt to enter the password.
First execution, appear the following error: ssh: connect to host 192.168.1.99 port 22: Connection refused, so start sshd program, to execute the script: # / etc/init d/sshd start, successfully solve the problem above.

As for the command of other parameters, usually work in the basic use, so, not for example, simply give you a translation 1, in order to do reference.

DESCRIPTION: describe
scp copies files between hosts on a network.   It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1).   Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
scp copies data between network hosts, and she USES ssh(1) for data transfer, using the same security verification method. Unlike rcp(1), scp asks for a password when necessary.

The options are as follows:
The specific options are as follows:
-1 Forces scp to use protocol 1.
    forces scp to use protocol 1

-2 Forces scp to use protocol 2.
Force scp to use protocol 2

-3 Copies between two remote hosts are transferred through the local host.Without this option the data is copied
  directly between the two remote hosts.Note that this option disables the progress meter.
Transfer data between two remote hosts via a local host. Without this option, the data will be copied directly between remote hosts. Note: this option does not support progress bar display.

-4 Forces scp to use IPv4 addresses only.
Force scp to use only the IPV4 address.

-6 Forces scp to use IPv6 addresses only.
  forces scp to use only the IPV6 address.


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

-C Compression enable.Passes the -C flag to ssh(1) to enable compression.
Enable compression. Pass the -C parameter to SSH to enable compression

-c cipher
  Selects the cipher to use for encrypting the data transfer.This option is directly passed to ssh(1).
  selects the password to encrypt the data transmission, and this option is passed directly to ssh(1).

-F ssh_config
  Specifies an alternative per-user configuration file for ssh.This option is directly passed to ssh(1).
Specify an interactive user profile for ssh, and this option is passed directly to ssh(1).

-l limit
  Limits the used bandwidth, specified in Kbit/s.
  limits the bandwidth used in units of Kb.


-P port
  Specifies the port to connect to on the remote host.
  specifies the link port on the remote host

-q Quiet mode
  silent mode:

-r Recursively copy entire directories
Recursively copies the entire directory

-S program
  Name of program to use for the encrypted connection.The program must understand ssh(1) options.
The program used to encrypt the link. The program needs options that recognize ssh(1).

EXIT STATUS
Post-execution state
The scp utility exits 0 on success, and > 0 if an error occurs.
When the scp tool command is successfully executed, the return code is 0, and any error occurs with a return code greater than 0


Related articles: