Linux SSh SCP uses "remote File/directory Transfer"

Source: Internet
Author: User
Tags sin secure copy

One: Introduction and function of the Linux ssh SCP: SCP is the shorthand for secure copy, a command for remotely copying files under Linux, and a similar command with CP, but the CP is only copied on this machine and cannot cross the server. Sometimes we need to get a file on a remote server that does not have an FTP server configured, or shared, and cannot get the files by conventional means, but only needs to be achieved with simple SCP commands.
One How to use the Linux ssh SCP 1copy the native files to the remote server
#scp/home/test/item.txt[email protected]:/etc/test
/home/test/the absolute path to the local file, item.txt the local file to be copied to the server, root log on to the remote server by root (or other users with equivalent privileges); 192.168.1.129 The IP address of the remote server (the domain name or machine name can also be used);/etc/test Copy the local file to the path located on the remote server;
Log in to the remote server through the root user and enter Yes to agree to an SSH connection;
Follow the prompts to enter the root user's password;
After the connection is established, the file is transferred, showing the percentage, actual time and transmission speed.
2upload the local directory to the remote server:# SCP - R/home/test/[email protected]:/etc/test

The-r parameter indicates a recursive copy (that is, the files and directories under the directory are copied);/home/test/indicates the directory to be uploaded,[email protected]:/etc/test to log on to the remote server using the root user:/etc/ Test indicates the location of the directory that is saved on the remote server.


3Copy the files on the remote server to the native
#scp [email protected]:/usr/local/sin.sh/home/testremote Log on to the remote server via a remotely user (you can also use other users with equivalent privileges)
www.abc.com the domain name of the remote server (you can also use the server IP address)
/usr/local/sin.sh files that are located on a remote server to be copied to this computer
/home/testr to copy remote files to the local absolute path 4to copy a directory on a remote server to a native# SCP - R[Email protected]:/user/local//home/test/

The R parameter indicates recursive replication (that is, copying files and directories under the directory); [email protected] means using the root user to log on to the remote server www.vpser.net,:/user/local/Represents the directory on the remote server. The/home/test/of the last face represents the path that is saved locally.

5 . Several parameters that may be useful:

-V is the same as-V in most Linux commands to show progress. Can be used to view connections, certifications, or configuration errors.

-C Enable compression option.

-4 forcibly use the IPV4 address.

-6 forcibly use IPV6 address


Note two points:
1. If the remote server firewall has special restrictions, the SCP will go to the special port, depending on what port, depending on the situation, the command format is as follows:
#scp-P 4588 [email Protected]:/usr/local/sin.sh/home/administrator
2. Use SCP be aware that the user you are using has permission to read the appropriate files for the remote server. Transfer files via SSH SSH into the other machine: SSH REMOTEIP
scp-rp/path/filename [Email Protected]:/path #将本地文件拷贝到服务器上
SCP-RP [Email Protected]:/path/filename/path #将远程文件从服务器下载到本地

Tar Cvzf-/path/| SSH [email protected] "cd/some/path/; Cat-path.tar.gz "#压缩传输
Tar Cvzf-/path/| SSH [email protected] "cd/some/path/; Tar Xvzf-"#压缩传输一个目录并解压

Linux SSh SCP uses "remote File/directory Transfer"

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.