Linux: scp remote file copy command

Linux scp command is used to copy files and directories between Linux.

scp is a secure copy of the abbreviation, scp remote file copy is based on ssh command for secure login linux system.

1, copied from local to remote

Format:

Their use is required to enter a password

scp local_file remote_username@remote_ip:remote_folder
或者
scp local_file remote_username@remote_ip:remote_file
样例:

scp /home/space/music/1.mp3 [email protected]:/home/root/others/music
scp /home/space/music/1.mp3 [email protected]:/home/root/others/music/001.mp3

1st, 2nd specifies the user name, need to re-enter the password after the command is executed, the first one specifies only a remote directory, file name change, the second specifies the file name;

Copy directory

Copy the directory command format:

scp -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder

===================

2, copied from remote to local

Replicated from the local to the remote, as long as the copy from the local to the remote command to reverse the order of two parameters, the following examples

Applications:

scp remote_user@remote_ip:remote_file local_file

scp -r remote_user@remote_ip:remote_dir local_dir

[email protected] SCP: / Home / the root / Others / Music /home/space/music/1.mp3
SCP -R & lt www.runoob.com:/home/root/others/ / Home / Space / Music /
Description
1. If the remote server firewall promising scp command sets the specified port, we need to use -P command to set the parameters of the port number, the command format is as follows:

#scp command port number 4588
scp -P 4588 [email protected]: /usr/local/sin.sh / Home / Administrator
2. To ensure scp the user having to read the corresponding remote file server permission or scp command is not work

Copy the code
parameter description:

-1: 强制scp命令使用协议ssh1
-2: 强制scp命令使用协议ssh2
-4: 强制scp命令只使用IPv4寻址
-6: 强制scp命令只使用IPv6寻址
-B: 使用批处理模式(传输过程中不询问传输口令或短语)
-C: 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
-p:保留原文件的修改时间,访问时间和访问权限。
-q: 不显示传输进度条。
-r: 递归复制整个目录。
-v:详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。
-c cipher: 以cipher将数据传输进行加密,这个选项将直接传递给ssh。
-F ssh_config: 指定一个替代的ssh配置文件,此参数直接传递给ssh。
-i identity_file: 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。
-l limit: 限定用户所能使用的带宽,以Kbit/s为单位。
-o ssh_option: 如果习惯于使用ssh_config(5)中的参数传递方式,
-P port:注意是大写的P, port是指定数据传输用到的端口号
-S program: 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。

Guess you like

Origin www.cnblogs.com/enumx/p/12309984.html