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

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

输入scp -h看看选项:

$ scp -h
unknown option -- h
usage: 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:-1      Forces scp to use protocol 1.-2      Forces scp to use protocol 2.-3      Copies 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.-4      Forces scp to use IPv4 addresses only.-6      Forces scp to use IPv6 addresses only.-B      Selects batch mode (prevents asking for passwords or passphrases).-C      Compression 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.-p      Preserves modification times, access times, and modes from the original file.-q      Quiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1).-r      Recursively 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.-v      Verbose 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>BSD                                                                                     September 25, 2015                                                                                     BSD

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

linux命令之远程文件或文件夹拷贝-scp相关推荐

  1. Linux命令行下复制粘贴文件

    Linux命令行下复制粘贴文件 一.复制单个文件 1.ls命令演示 2.cp命令 二.复制文件夹 1.cp -r 命令 三.复制多个文件 一.复制单个文件 1.ls命令演示 2.cp命令 我们下面将1 ...

  2. Linux下导出MySQL为SQL文件_在linux命令下导出导入.sql文件的方法

    本文讲述了在linux命令下导出导入.sql文件的方法.分享给大家供大家参考,具体如下: 一.导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径): 1.导出数据和表结构: ...

  3. Linux命令--tac(倒序查看文件所有内容)

    原文网址:Linux命令--tac(倒序查看文件所有内容)_IT利刃出鞘的博客-CSDN博客 简介 本文介绍Linux的tac命令的用法. tac用于倒序查看文件的所有内容.(跟cat命令相反). 示 ...

  4. Linux命令--more(查看日志文件内容,排查问题)

    原文网址:Linux命令--more(查看日志文件内容,排查问题)_IT利刃出鞘的博客-CSDN博客 简介 说明 本文介绍Linux的more命令的用法. more命令适用于查看比较大的文件,例如:日 ...

  5. linux下刻录光盘读取不了_怎么从Linux命令行刻录镜像文件到DVD光盘中

    当我们在操作Linux系统的时候,需要将镜像文件刻录到DVD中,那么要怎么做呢?下面小编给大家介绍下怎么从Linux命令行刻录镜像文件到DVD中,一起来学习下吧. 最常见的两种镜像文件格式是ISO(. ...

  6. MobaXterm连接远程服务器,使用Linux命令行上传下载文件

    文章目录 一.MobaXterm连接远程服务器 二.Linux命令行上传和下载文件 三.服务器挂载U盘传输文件 四..ipynb文件转化为.py文件 五.关闭本地电脑,服务器运行python 项目 问 ...

  7. Linux之scp命令实现远程服务器的文件拷贝

    scp就是secure copy,一个在linux下用来进行远程拷贝文件的命令. 有时我们需要获得远程服务器上的某个文件,该服务器既没有配置ftp服务器,也没有做共享,无法通过常规途径获得文件时,只需 ...

  8. linux文件一列加1,Linux命令(1)-创建文件

    版本:centos7 1.可以使用cat创建一个新的文件 命令:cat>>filename 使用cat创建文件时,以系统默认的文件属性作为新文件的属性,并接受键盘输入作为文件的内容.输入结 ...

  9. Linux 命令之 sftp -- 交互式的文件传输程序

    文章目录 一.命令介绍 二.常用选项 三.参考示例 (一)使用 sftp 连接远程主机 (二)使用 sftp 上传文件到远程主机 (三)使用 sftp 从远程主机下载文件 (四)查看远程主机的当前目录 ...

最新文章

  1. Oracle游标学习笔记
  2. spring源码分析之@Conditional
  3. 操作系统-银行家算法
  4. 手写springboot_Spring Boot 入门教程 | 图文讲解
  5. 五年26个版本:Linux系统内核全程回顾
  6. 页面平滑过渡全屏切换
  7. xml没有提示解决办法eclipse
  8. Python pow() 函数
  9. Spring Boot AOP的使用
  10. 用c#中的WebBrowser抢小米F码,抢小米手机以及自动测试实现原理
  11. unix操作系统图标大全
  12. 160个crackme 008 Andrénalin.1
  13. 高职院校汽车相关专业AEB测试套件及自动驾驶相关传感器介绍
  14. 交点处批量性一次打断lisp_cad批量交点打断.VLX
  15. 墨云科技获蓝驰创投数千万元投资,用人工智能升级网络安全服务
  16. keil5工程函数无法跳转到函数定义解决方法
  17. DSP_TMS320F28377D_eCAP学习笔记
  18. VSLAM学习记录-求导:李群与李代数
  19. layui.css地址,layui+高德获取经纬度(可点击更换位置)
  20. 金蝶K/3 Cloud 实施笔记

热门文章

  1. alter table add column多个字段_WordPress 在文章列表快速编辑中编辑自定义字段
  2. C++中的hash_map和map的区别
  3. Vue.js 进入/离开 列表过渡
  4. 历年软件设计师下午考试试题汇总统计(更新至2016年上半年)
  5. 数据库范式1NF 2NF 3NF BCNF
  6. LaTeX TeXworks编辑器插入.eps图片时,无法识别的扩展名eps
  7. Python-OpenCV 杂项(二)(三): 鼠标事件、 程序性能的检测和优化
  8. 深度学习(十九)基于空间金字塔池化的卷积神经网络物体检测-ECCV 2014
  9. 如何设计一门语言(十一)——删减语言的功能
  10. 数字图像处理:第一章 概述