Linux instructions in detail SCP transfer files between Linux hosts

Source: Internet
Author: User
Tags ssh port

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.