300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux命令之远程文件或文件夹拷贝-scp

linux命令之远程文件或文件夹拷贝-scp

时间:2022-01-27 15:47:54

相关推荐

linux命令之远程文件或文件夹拷贝-scp

在linux安装部署或者升级分布式系统时,经常要重当前主机拷贝文件到集群中其他的主机节点,或者从其他主机节点拷贝文件到当前主机。

我们知道cp命令是同一主机下面文件的拷贝,而scp命令就是linux下实现远程主机之间文件拷贝的命令,支持向远程主机‘推文件’和向远程主机‘拉文件’的方式。

输入scp -h看看选项:

$ scp -hunknown option -- husage: 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

列出了一些选项和大致的用法,不过具体选项是什么意思并不知道。

输入man scp看看说明:

SCP(1) BSD General Commands Manual SCP(1)NAMEscp — secure copy (remote file copy program)SYNOPSISscp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2DESCRIPTIONscp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords orpassphrases if they are needed for authentication.File names may contain a user and host specification to indicate that the file is to be copied to/from that host. Local file names can be made explicit using absolute or relative pathnamesto avoid scp treating file names containing ‘:’ as host specifiers. Copies between two remote hosts are also permitted.The options are as follows:-1Forces scp to use protocol 1.-2Forces scp to use protocol 2.-3Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option dis‐ables the progress meter.-4Forces scp to use IPv4 addresses only.-6Forces scp to use IPv6 addresses only.-BSelects batch mode (prevents asking for passwords or passphrases).-CCompression enable. Passes the -C flag to ssh(1) to enable compression.-c cipherSelects the cipher to use for encrypting the data transfer. This option is directly passed to ssh(1).-F ssh_configSpecifies an alternative per-user configuration file for ssh. This option is directly passed to ssh(1).-i identity_fileSelects the file from which the identity (private key) for public key authentication is read. This option is directly passed to ssh(1).-l limitLimits the used bandwidth, specified in Kbit/s.-o ssh_optionCan be used to pass options to ssh in the format used in ssh_config(5). This is useful for specifying options for which there is no separate scp command-line flag. For fulldetails of the options listed below, and their possible values, see ssh_config(5).AddressFamilyBatchModeBindAddressCanonicalDomainsCanonicalizeFallbackLocalCanonicalizeHostnameCanonicalizeMaxDotsCanonicalizePermittedCNAMEsCertificateFileChallengeResponseAuthenticationCheckHostIPCipherCiphersCompressionCompressionLevelConnectionAttemptsConnectTimeoutControlMasterControlPathControlPersistGlobalKnownHostsFileGSSAPIAuthenticationGSSAPIDelegateCredentialsHashKnownHostsHostHostbasedAuthenticationHostbasedKeyTypesHostKeyAlgorithmsHostKeyAliasHostNameIdentityFileIdentitiesOnlyIPQoSKbdInteractiveAuthenticationKbdInteractiveDevicesKexAlgorithmsLogLevelMACsNoHostAuthenticationForLocalhostNumberOfPasswordPromptsPasswordAuthenticationPKCS11ProviderPortPreferredAuthenticationsProtocolProxyCommandPubkeyAcceptedKeyTypesPubkeyAuthenticationRekeyLimitRhostsRSAAuthenticationRSAAuthenticationSendEnvServerAliveIntervalServerAliveCountMaxStrictHostKeyCheckingTCPKeepAliveUpdateHostKeysUsePrivilegedPortUserUserKnownHostsFileVerifyHostKeyDNS-P portSpecifies the port to connect to on the remote host. Note that this option is written with a capital ‘P’, because -p is already reserved for preserving the times and modes of thefile.-pPreserves modification times, access times, and modes from the original file.-qQuiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1).-rRecursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.-S programName of program to use for the encrypted connection. The program must understand ssh(1) options.-vVerbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.EXIT STATUSThe scp utility exits 0 on success, and >0 if an error occurs.SEE ALSOsftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh_config(5), sshd(8)HISTORYscp is based on the rcp program in BSD source code from the Regents of the University of California.AUTHORSTimo Rinne <tri@iki.fi>Tatu Ylonen <ylo@cs.hut.fi>BSDSeptember 25, BSD

里面常用的选项有,-r 拷贝目录,-v 显示拷贝时的调试信息,对于拷贝文件出错有帮助,-l 限制拷贝时带宽等。

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