Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

9.2.3 Remote transfer command


May 24, 2021 That's what Linux should learn



scp (secure copy) is a command that transmits securely between networks based on the SSH protocol in the format "scp (parameter) local file Remote account s remote IP address: remote directory".

Unlike the cp command explained in Chapter 2, the cp command can only replicate files on the local hard drive, and scp not only transmits data over the network, but all data is encrypted. F or example, if you want to pass some files over the network from one host to another, which happens to be Linux systems, the scp command makes it easy to pass files. The parameters available in the scp command and their function are shown in Table 9-2.

The parameters and effects available in the Table 9-2 scp command

Parameter Action -v shows detailed connection progress -P specifies the sshd port number of the remote host -r for transferring folders -6 Using the IPv6 protocol When using the scp command to copy files locally to the remote host, you first need to write the location of the local files in an absolute path. I f you want to transfer all the data within the entire folder, you also need to add additional parameters -r for recursive operations. T hen write the IP address of the remote host to be delivered to, and the remote server will request authentication. T he current user name is root, and the password is the password for the remote server. I f you want to authenticate with the identity of the specified user, you can use the parameter format of the user name, host address. F inally, you need to add a colon after the ip address of the remote host and write later which folder to transfer to the remote host. A s long as the parameters are correct and the user's identity is successfully verified, the transfer work can begin. Because the scp command is based on the SSH protocol for file transfer, and section 9.2.2 sets up key verification, the current transfer of files, do not require an account and password.

root@linuxprobe LinuxProbe.Com scp/root.txt/readme.txt root@linuxprobe 192.168.10.20:/home [email protected]'. s password: Enter the password of the root administrator in the remote server here readme.txt 100% 26 0.0KB/s 00:00 in addition, you can also use the scp command to download files on the remote host to the local host, the command format is "scp (parameters) remote user remote IP address: remote file local directory". For example, you can download the system version information file of the remote host, so that you do not have to log on to the remote host, and then file transfer, it also saves a lot of twists and turns.

root@linuxprobe scp 192.168.10.20:/etc/redhat-release/root [email protected]'s password: enter the remote server here Root administrator's password redhat-release 100% 52 0.1KB/s 00:00 root@linuxprobe s cat redhat-release Red Enterprise Linux Server release 7.0 (Maipo)