Linux SCP command (copying files between hosts and servers)

Source: Internet
Author: User
Tags scp command secure copy

SCP is secure copy, a command used to remotely copy files in Linux.
Sometimes we need to obtain a file on the remote server. This server is neither configured with an FTP server nor shared. When files cannot be obtained through conventional channels, you only need to use the simple SCP command to achieve the goal.

1. Copy local files to a remote server

# SCP/home/Administrator/news.txt root@

/Home/Administrator/absolute path of the local file
Copy news.txt to a local file on the server
Root log on to the remote server using the root user (other users with the same permissions can also be used)
IP address of the remote server (domain name or machine name can also be used)
/Etc/squid: copy the local file to the path on the remote server

Log on to the remote server as the root user and enter yes to agree to create an SSH connection.

Enter the root user password as prompted

After the connection is established, the file is transmitted, showing the percentage, actual time, transmission speed, and other information.

2. Copy files on the remote server to the Local Machine

# SCP sh/home/Administrator

Remote users can log on to the remote server (other users with the same permissions can also be used)
Domain Name of the remote server (the IP address of the server can also be used)
/Usr/local/sin. Sh file to be copied to the local Remote Server
/Home/Administrator copy the remote file to the local absolute path

1. If the remote server firewall has special restrictions, SCP must go through the special port. The specific port used depends on the situation. The command format is as follows:
# SCP-P 4588 sh/home/Administrator
2. When using SCP, pay attention to whether the user has the permission to read the corresponding files on the remote server.


Make sure that the SSH service is enabled on the remote Linux server. SCP seems to be a command in SSH.

You can first try to log on to SSH username @ remoteserver through SSH.

If you confirm that SSH is available, enter exit to exit.

For example, I want to test all the files from the/etc folder of remoteserver to the local/tmp/etc folder.

SCP-r username @ remoteserver:/etc/tmp/etc

For example, to test all the files from the/etc/a.txt file of remoteserver to the local/tmp/etcfile, a.txt is also called.

SCP username @ remoteserver:/etc/a.txt/tmp/etc/a.txt

Besides, this parameter-R is used in many places. For example, CP can only copy files instead of folders, but CP-R is omnipotent and can copy everything, files or folders.

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: 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.