如何在 Linux 上复制文件/文件夹到远程系统? | Linux 中国

找不到分类 evilven 3个月前 (08-28) 82次浏览 已收录 0个评论 扫描二维码
如何在 Linux 上复制文件/文件夹到远程系统? | Linux 中国

从一个服务器复制文件到另一个服务器,或者从本地到远程复制是 Linux 管理员的日常任务之一。

— Prakash Subramanian


如何在 Linux 上复制文件/文件夹到远程系统? | Linux 中国
从一个服务器复制文件到另一个服务器,或者从本地到远程复制是 Linux 管理员的日常任务之一。

我觉得不会有人不同意,因为无论在哪里这都是你的日常操作之一。有很多办法都能处理这个任务,我们试着加以概括。你可以挑一个喜欢的方法。当然,看看其他命令也能在别的地方帮到你。

我已经在自己的环境下测试过所有的命令和脚本了,因此你可以直接用到日常工作当中。

通常大家都倾向 scp,因为它是文件复制的原生命令native command之一。但本文所列出的其它命令也很好用,建议你尝试一下。

文件复制可以轻易地用以下四种方法。

◈ scp:在网络上的两个主机之间复制文件,它使用 ssh 做文件传输,并使用相同的认证方式,具有相同的安全性。
◈ rsync:是一个既快速又出众的多功能文件复制工具。它能本地复制、通过远程 shell 在其它主机之间复制,或者与远程的 rsync 守护进程daemon 之间复制。
◈ pscp:是一个并行复制文件到多个主机上的程序。它提供了诸多特性,例如为 scp 配置免密传输,保存输出到文件,以及超时控制。
◈ prsync:也是一个并行复制文件到多个主机上的程序。它也提供了诸多特性,例如为 ssh配置免密传输,保存输出到 文件,以及超时控制。

方式 1:如何在 Linux 上使用 scp 命令从本地系统向远程系统复制文件/文件夹?

scp 命令可以让我们从本地系统复制文件/文件夹到远程系统上。

我会把 output.txt 文件从本地系统复制到 2g.CentOS.com 远程系统的 /opt/backup 文件夹下。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt                                                                                              </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">     </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s   </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

从本地系统复制两个文件 output.txt 和 passwd-up.sh 到远程系统 2g.CentOs.com 的 /opt/backup 文件夹下。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

从本地系统复制 shell-script 文件夹到远程系统 2g.CentOs.com 的 /opt/back文件夹下。

这会连同shell-script 文件夹下所有的文件一同复制到/opt/back 下。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> root@</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh      </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">76</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.1KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">7</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">23</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

方式 2:如何在 Linux 上使用 scp 命令和 Shell 脚本复制文件/文件夹到多个远程系统上?

如果你想复制同一个文件到多个远程服务器上,那就需要创建一个如下面那样的小 shell 脚本。

并且,需要将服务器添加进 server-list.txt 文件。确保添加成功后,每个服务器应当单独一行。

最终,你想要的脚本就像下面这样:

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt root@$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

完成之后,给 file-copy.sh 文件设置可执行权限。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;"><li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">chmod</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">+</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">x </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li></ol>

最后运行脚本完成复制。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

使用下面的脚本可以复制多个文件到多个远程服务器上。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh root@$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

下面结果显示所有的两个文件都复制到两个服务器上。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">cp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

使用下面的脚本递归地复制文件夹到多个远程服务器上。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">  </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> root@$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

上述脚本的输出。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">cp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh      </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">76</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.1KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">7</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">23</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.4KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh      </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">76</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.1KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">877</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.9KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">7</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">23</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.0KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

方式 3:如何在 Linux 上使用 pscp 命令复制文件/文件夹到多个远程系统上?

pscp 命令可以直接让我们复制文件到多个远程服务器上。

使用下面的 pscp 命令复制单个文件到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">H </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">46</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">11</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

使用下面的 pscp 命令复制多个文件到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">H </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">47</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">48</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

使用下面的 pscp 命令递归地复制整个文件夹到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">H </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/ /</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">48</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">46</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

使用下面的 pscp 命令使用下面的命令复制单个文件到多个远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">h server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">49</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">48</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">49</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">48</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">Debian</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

使用下面的 pscp 命令复制多个文件到多个远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">h server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">50</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">30</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">Debian</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">50</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">30</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

使用下面的命令递归地复制文件夹到多个远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> pscp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">pssh </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">h server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/ /</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">opt</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">51</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">31</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">Debian</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">18</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">51</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">31</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">[</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">SUCCESS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">]</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span></code></section></li>
</ol>

方式 4:如何在 Linux 上使用 rsync 命令复制文件/文件夹到多个远程系统上?

rsync 是一个即快速又出众的多功能文件复制工具。它能本地复制、通过远程 shell 在其它主机之间复制,或者在远程 rsync 守护进程daemon 之间复制。

使用下面的 rsync 命令复制单个文件到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avz </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt root@</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">598</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">31</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1258.00</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2468</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.92</span></code></section></li>
</ol>

使用下面的 rsync 命令复制多个文件到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avz </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">737</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">50</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">1574.00</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2537</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.22</span></code></section></li>
</ol>

使用下面的 rsync 命令通过 ssh 复制单个文件到远程服务器。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avzhe </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">ssh</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">598</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">31</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">419.33</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.47K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.92</span></code></section></li>
</ol>

使用下面的 rsync 命令通过 ssh 递归地复制文件夹到远程服务器。这种方式只复制文件不包括文件夹。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avzhe </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">ssh</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.85K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">281</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">8.26K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">9.12K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.21</span></code></section></li>
</ol>

方式 5:如何在 Linux 上使用 rsync 命令和 Shell 脚本复制文件/文件夹到多个远程系统上?

如果你想复制同一个文件到多个远程服务器上,那也需要创建一个如下面那样的小 shell 脚本。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avzhe </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">ssh</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">home</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">daygeek</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">shell</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">script</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

上面脚本的输出。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.86K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">281</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">8.28K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">9.13K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.21</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.86K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">281</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.76K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">9.13K</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2.21</span></code></section></li>
</ol>

方式 6:如何在 Linux 上使用 scp 命令和 Shell 脚本从本地系统向多个远程系统复制文件/文件夹?

在上面两个 shell 脚本中,我们需要事先指定好文件和文件夹的路径,这儿我做了些小修改,让脚本可以接收文件或文件夹作为输入参数。当你每天需要多次执行复制时,这将会非常有用。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r $1 root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

输入文件名并运行脚本。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh output1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3558</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.5KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">output1</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">txt </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3558</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.5KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

方式 7:如何在 Linux 系统上用非标准端口复制文件/文件夹到远程系统?

如果你想使用非标准端口,使用下面的 shell 脚本复制文件或文件夹。

如果你使用了非标准Non-Standard端口,确保像下面 scp 命令那样指定好了端口号。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">scp</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">P </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">2222</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">r $1 root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

运行脚本,输入文件名。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3558</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.5KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">ovh</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">100</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">%</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3558</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">3.5KB</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">s </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">00</span></code></section></li>
</ol>

如果你使用了非标准Non-Standard端口,确保像下面 rsync 命令那样指定好了端口号。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">rsync</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">!</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/bin/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">for</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> server </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">in</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">`more server-list.txt`</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">do</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">rsync </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">avzhe </span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">'ssh -p 2222'</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> $1 root@2g</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="typ" style="overflow-wrap: break-word;color: rgb(137, 189, 255);">CentOS</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">com$server</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">:</span><span class="str" style="overflow-wrap: break-word;color: rgb(101, 176, 66);">/opt/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">backup</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">done</span></code></section></li>
</ol>

运行脚本,输入文件名。

<ol class="linenums list-paddingleft-2" style="margin-left: 2em;margin-right: 2em;">
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="com" style="overflow-wrap: break-word;color: rgb(174, 174, 174);font-style: italic;">#</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">./</span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">copy</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">rsync</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">238</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">35</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">26.00</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">159</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.58</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sending incremental </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">file</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">list</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">passwd</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">-</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">up</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">.</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sh</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sent </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">238</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes received </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">35</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">26.00</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> bytes</span><span class="pun" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">/</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">sec</span></code></section></li>
<li><section style="overflow-wrap: break-word;width: 1200px;max-width: 1200px !important;"><code style="overflow-wrap: break-word;background: none;color: rgb(33, 150, 243);line-height: 1.2em;padding-left: 10px !important;border-radius: 0px !important;margin-top: 1em !important;margin-bottom: 1em !important;border-width: initial !important;border-style: none !important;border-color: initial !important;"><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);">total </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">size</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">159</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> speedup </span><span class="kwd" style="overflow-wrap: break-word;color: rgb(226, 137, 100);">is</span><span class="pln" style="overflow-wrap: break-word;color: rgb(184, 255, 184);"> </span><span class="lit" style="overflow-wrap: break-word;color: rgb(51, 135, 204);">0.58</span></code></section></li>
</ol>

via: https://www.2daygeek.com/linux-scp-rsync-pscp-command-copy-files-folders-in-multiple-servers-using-shell-script/

作者:Prakash Subramanian[2] 选题:lujun9972 译者:LuuMing 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

如何在 Linux 上复制文件/文件夹到远程系统? | Linux 中国


Hacking For Fun , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Linux 上复制文件/文件夹到远程系统? | Linux 中国
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址