directive: SCP
Copying files between different Linux hosts
File copy with security, SSH-based login.
Some Linux distributions do not have their own SCP, so you need to install SCP
# yum-y Install openssh-clients
Basic syntax:
# SCP [parameter] source target
Common parameters
-V: Show progress and can be used to view connections, certifications, or configuration errors
-R: Assigning a value directory
-C: Enable compression option
-P: Select port
-4: Forcibly use IPV4 address
-6: Forcibly use IPV6 address
Common ways to use:
1. copy locally to remote
1.1# SCP Local_file [email protected]_ip:remote_folder
1.2# SCP Local_file [email protected]_ip:remote_folder/remote_file
1.3# SCP Local_file remote_ip:remote_folder
1.4# SCP Local_file remote_ip:remote_folder/remote_file
1.1 and 1.2 Specify a user name, which requires the password of the remote server to be entered after the command executes
1.3 and 1.4 Do not specify a user name, you need to enter the user name and password of the remote server after the command executes
1.1 and 1.3 Only specify the remote directory, the file name does not change
1.2 and 1.4 Specify the remote directory and the file name
Example:
# scp/doiido/hello.sh [Email Protected]:/doiido
# scp/doiido/hello.sh [Email protected]:/doiido/newhello.sh
# scp/doiido/hello.sh 192.168.100.2:/doiido
# scp/doiido/hello.sh 192.168.100.2:/doiido/newhello.sh
2, will remote replication to local
from remote Copy to local, as long as the copy from the local to the remote command of the following 2 parameter swap order, as the syntax, here is only a list of examples;
# SCP [Email protected]:/doiido/doiido/hello.sh
# SCP [Email protected]:/doiido/hello.sh/doiido/newhello.sh
# SCP 192.168.100.2:/doiido/doiido/hello.sh
# SCP 192.168.100.2:/doiido/hello.sh/doiido/newhello.sh
3. Copy Directory
When the directory needs to be transferred, only need to add the parameter-R is possible, for example
# scp-r/doiido/hello/[email protected]:/doiido/
4. Note:
4.1: If the remote server modifies the SSH port, SCP needs to use the modified port, such as the remote server SSH port is 2222, you need to add the-p parameter:
# scp-p 2222/doiido/hello.sh [email Protected]:/doiido
4.2: Before using SCP, you need to confirm that the user of the remote connection has permission to read the corresponding file on the remote server. It is also important to note that the user executing the SCP directive has permission to the corresponding local directory.
Linux instructions in detail SCP transfer files between Linux hosts