2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > Linux命令行二:远程复制命令 scp

Linux命令行二:远程复制命令 scp

时间:2021-06-01 01:07:31

相关推荐

Linux命令行二:远程复制命令 scp

在 linux 下 scp 命令主要用来在不同主机之间做数据(文件或者目录)的安全拷贝的。scp 命令可以将数据(文件或者目录)从本地计算机中拷贝到远程计算机中,或者从远程计算机中拷贝数据(文件或者目录)到本地计算机,scp 命令使用安全加密协议,所以在远程拷贝数据的时候会比较安全,不会被黑客截取。如有不正之处,欢迎批评指正。

一、scp 命令

语法:

scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file][-l limit] [-o ssh_option] [-P port] [-S program][[user@]host1:]file1 ... [[user@]host2:]file2

参数项:

-1强制scp命令使用协议ssh1。-2强制scp命令使用协议ssh2.-3Copies between two remote hosts are transferred through the local host. Without this option the data is copied directlybetween the two remote hosts. Note that this option disablesthe progress meter.-4强制scp命令仅使用IPv4进行传输。-6强制scp命令仅使用IPv6进行传输。-B使用批处理模式(传输过程中不询问传输口令或短语)。-C允许压缩。(将-C标志传递给ssh,从而打开压缩功能)。-ccipher 以cipher将数据传输进行加密,这个选项将直接传递给ssh。-Fssh_config 指定一个替代的ssh配置文件,此参数直接传递给ssh。 -iidentity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。-llimit 限定用户所能使用的带宽,以Kbit/s为单位。 -ossh_option 如果习惯于使用ssh_config(5)中的参数传递方式。参数如下:AddressFamilyBatchModeBindAddressCanonicalDomainsCanonicalizeFallbackLocalCanonicalizeHostnameCanonicalizeMaxDotsCanonicalizePermittedCNAMEsCertificateFileChallengeResponseAuthenticationCheckHostIPCipherCiphersCompressionCompressionLevelConnectionAttemptsConnectTimeoutControlMasterControlPathControlPersistGlobalKnownHostsFileGSSAPIAuthenticationGSSAPIDelegateCredentialsHashKnownHostsHostHostbasedAuthenticationHostbasedKeyTypesHostKeyAlgorithmsHostKeyAliasHostNameIdentitiesOnlyIdentityAgentIdentityFileIPQoSKbdInteractiveAuthenticationKbdInteractiveDevicesKexAlgorithmsLogLevelMACsNoHostAuthenticationForLocalhostNumberOfPasswordPromptsPasswordAuthenticationPKCS11ProviderPortPreferredAuthenticationsProtocolProxyCommandProxyJumpPubkeyAcceptedKeyTypesPubkeyAuthenticationRekeyLimitRhostsRSAAuthenticationRSAAuthenticationSendEnvServerAliveIntervalServerAliveCountMaxStrictHostKeyCheckingTCPKeepAliveUpdateHostKeysUsePrivilegedPortUserUserKnownHostsFileVerifyHostKeyDNS-Pport 注意是大写的P, port是指定数据传输用到的端口号。 -p保留原文件的修改时间,访问时间和访问权限。-qquiet模式:不显示传输进度条。-r递归复制整个目录。-Sprogram 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。-vVerbose模式:详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。

二、常用命令

从本地计算机复制目录到远程计算机上

将本地计算机/home/tools目录复制到远程计算机(IP:10.10.10.10)的/home/tools1/目录,复制后的目录结构为/home/tools1/tools

-r 级联复制目录及子目录的内容-P 远程计算机上的ssh端口root 远程计算机用户名

scp -r -P 2222 /home/tools/ root@10.10.10.10:/home/tools1

如果只想复制/home/tools/目录下的内容到/home/tools1/目录。命令如下:

scp -r -P 2222 /home/tools/* root@10.10.10.10:/home/tools1

从远程计算机复制目录到本地计算机上

将远程计算机(IP:10.10.10.10)/home/tools目录复制到本地计算机的/home/tools1/目录,复制后的目录结构为/home/tools1/tools

-r 级联复制目录及子目录的内容-P 远程计算机上的ssh端口root 远程计算机用户名

scp -r -P 2222 root@10.10.10.10:/home/tools /home/tools1/

如果只想复制/home/tools/目录下的内容到/home/tools1/目录。命令如下:

scp -r -P 2222 root@10.10.10.10:/home/tools/* /home/tools1/

三、参考资料

scp 命令详解

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。