A method for obtaining remote files from the SCP command in Linux _linux shell

Source: Internet
Author: User
Tags ssh file permissions scp command scp command in linux secure copy ssh port

First, what is the SCP?

SCP is a secure copy of the shorthand for remote copy of files under Linux commands, and its similar command has CP, but the CP is only on the local copy not across the server, and the SCP transmission is encrypted, may slightly affect the speed.

Second, what is the use of SCP?

1, we need to get a file on the remote server, the remote server has neither configured the FTP server, did not open the Web server, did not do the sharing, can not get the file through the regular way, only need to pass the SCP command can easily achieve the goal;

2, we need to upload the files on this machine to the remote server, the remote server does not open the FTP server or share, can not be uploaded through the normal way, at this time can also be through the SCP command can easily achieve the purpose;

Iii. methods of using SCP

1, get the files on the remote server

# cp-p 2424 username@ (IP or remote service alias):/home/username/a.tar.gz/home/username/
-P 2424 indicates that the port after the SSH port is changed, and if the SSH port is not changed, you do not need to add the parameter;

Username@ip means to log on to the remote server using the specified user;

2, get the directory on the remote server

# scp-p 2424-r name@ip:/home/name/aaa//home/name/
The-r parameter represents recursive replication (that is, copying files and directories below the directory);

name@ip:/home/name/aaa/that the contents of the AAA folder in the user's home directory on the remote server are copied to the local directory;

/home/name/represents the path saved locally;

3, upload the local files to the server

# scp-p 2424 ~/aaa.tar.gz name@ip:/home/user/
Indicates that the files of the local user's home directory are uploaded to the user's home directory on the remote server;

4, upload the local directory to the server

# scp-p 2424-r ~/aaa/name@ip:/home/user/bbb/
It means that all files in the local home Directory AAA folder are passed to the BBB folder in the remote service user's home directory;

5, a number of possible useful parameters:

-P Port;

-p means to maintain file permissions;

-R represents recursive replication;

-V, as in most Linux commands, is used to show progress and can be used to view connectivity, authentication, or configuration errors;

-c enable compression options;

-4 forcibly uses IPV4 address;

-6 forcibly uses IPV6 address;

The above is a small set of Linux in the introduction of the SCP command to get the remote file method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.