Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the scp command in linux

Shulou Source: shulou.com Published: 2022-06-01 14:04:38 09月16日 Update

Editor to share with you how to use the scp command in linux. I hope you will get something after reading this article. Let's discuss it together.

Scp is the abbreviation of secure copy. It is a secure remote file copy command based on ssh login in linux system. Scp is encrypted, rcp is unencrypted, and scp is an enhanced version of rcp.

The basic format scp source target copies local files to the remote server [student@servera ~] scp log.tar root@serverb:/logbackupThe authenticity of host 'serverb (172.25.250.11)' can't be established.ECDSA key fingerprint is SHA256:BCd8VCfEpGbUo3zb1De0hd1Q5nOMEzYNpMFu5o7j4Fg.Are you sure you want to continue connecting (yes/no)? YesWarning: Permanently added 'serverb,172.25.250.11' (ECDSA) to the list of known hosts.root@serverb's password:log.tar 100% 11MB 20.8MB/s 00:00 [student@servera ~] ssh root@serverb "ls / logbackup" root@serverb's password:log.tarroot@ is optional, if not specified, use your current local user. The user you are using must have permissions on the corresponding directory on the remote host. As with ssh, the first time you connect, there is a security prompt, and the option yse is fine, because scp is part of OpenSSH. Copy files from the remote end to the local [student@servera ~] scp root@serverb:/logbackup/log.tar backup/root@serverb's password:log.tar 100% 11MB 25.5MB/s 00:00 [student@servera ~] ls backup/log.tar

If it is a directory, we can copy the entire directory content by recursively using the-r option

[student@servera] $scp-r root@serverb:/var/log/ backup/root@serverb's password:lastlog 100 285KB 5.9MB/s 00:00 README 100 1040 260.8KB/s 00:00 wtmp 6912 2.6MB/s 00:00 btmp 100 0.0KB/s 00:00 audit.log 100 208KB 8.0MB/s 00:00 sssd.log 100% 0 0.0KB/s 00:00 sssd_implicit_files.log 100 9 32.9KB/s 00:00 sssd_nss.log 100 94 8.6KB/s 00:00 Rhsm.log 3642 1.0MB/s 00:00 tuned.log 2434 904.9KB/s 00:00 messages 100 1459KB 18.1MB/s 00:00 Secure 8298 3.4MB/s 00:00 maillog 100 0.0KB/s 00:00 spooler 100 0.0KB/s 00:00 dnf.log 100% 107KB 3.4MB/s 00:00 dnf.librepo.log 100% 245KB 8.4MB/s 00:00 dnf.rpm.log 100% 21KB 2 .3MB / s 00:00 hawkey.log 100 18KB 3.8MB/s 00:00 cron 100 7166 706.4KB/s 00:00 boot.log 100 0 0.0KB/s 00:00

We can also use scp to copy a file from one remote host to another.

[student@workstation] scp student@servera:/home/student/log.tar student@serverb:/home/student/student@serverb's password:log.tar 100% 670KB 19.6MB/s 00:00 Connection to servera closed. [student@workstation ~] ssh student@serverb "ls-l" total 672 Murray RW Murray. 1 student student 686080 Nov 6 20:54 log.tar finished reading this article, I believe you have a certain understanding of "how to use scp commands in linux". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Files commands hosts directories security users articles encryption content can be passed security done that is copy way time more server permissions format Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft NVidia Linux Redmi