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
You may be confused after seeing the various parameters and options above. However, it doesn’t matter, let’s break it into parts and analyze them one by one.
Actually, this command is very similar to the cp we usually use.
scp The simplest usage is scp [[user@]host1:]file1 ... [[user@]host2:]file2, can you understand it?
It doesn’t matter if you don’t understand it. Let’s give an example: I want to copy the /home/oracle/*.tar files from the Linux host 192.168.1.2 to the /home/siebel of the Linux host 192.168.1.3. It can be written in the above format:
scp oracle@192.168.1.2:/home/oracle/*.tar siebel@192.168.1.3:/siebel/
After entering the above command, press enter and line change to confirm, which may cause You enter the password, enter the password according to the prompts.
When executing for the first time, the following error occurred: ssh: connect to host 192.168.1.99 port 22: connection refused, so the sshd program was started and the script was executed: # /etc/init.d/sshd start, successfully solved above questions.
As for the other parameters of this command, they are basically not used in daily work, so I won’t give examples. I will simply translate them for your reference.
description: Description
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. It uses ssh(1) for data transmission and uses the same security authentication method. Unlike rcp(1), scp will ask 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.
Forces 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 through the local host. Without this option, 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.
Forces scp to use only ipv4 addresses.
-6 forces scp to use ipv6 addresses only.
Forces scp to use only ipv6 addresses.
-b selects batch mode (prevents asking for passwords or passphrases).
Use batch mode (prevents asking for passwords or passphrases)
-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 cipher to use for encrypting the data transfer. transport, 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).
Specifies an interactive user configuration file for ssh, this option is Passed directly to ssh(1).
-l limit
limits the used bandwidth, specified in kbit/s.
Limits the used bandwidth, in 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 copy entire directories
-s program
name of program to use for the encrypted connection.the program must understand ssh(1) options.
Program used to encrypt links. This program needs to be able to recognize the ssh(1) options.
exit status
Post-execution status
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, Any error return code is greater than 0
The above is the detailed content of How to use the linux advanced copy command scp. For more information, please follow other related articles on the PHP Chinese website!