banner
Aki

Aki

太阳能维修,月亮可更换,星星不闪包退换。
twitter

Copying files between different hosts under Linux

Copying Files Between Different Hosts on Linux#

Prerequisites#

The two target hosts for file copying should be able to communicate. The local end should have scp.

SCP Command#

Command format: scp [source file path] [destination file path]

Usage:

usage: scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file]
            [-J destination] [-l limit] [-o ssh_option] [-P port]
            [-S program] source ... target

1. Copying files from the local end to the destination end#

scp /root/a [email protected]:/root/b

Here, "a" and "b" are the file names, which can be different.

2. Copying files from the destination end to the local end#

scp [email protected]:/root/a /root/b

3. Note#

If you want to copy a folder, add -r after scp.

Since scp is based on the ssh port, it transfers files using the default local port to the remote port. If the ssh ports on both ends are different or there are port restrictions, you need to specify them again by adding -P after the scp command. The "P" must be capitalized. Refer to the scp usage.

4. Unusual Usage#

Can you copy files from a remote end to another remote end? Yes, you can.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.