rsync - Linux Security Cookbook - Recipe 6.3 Copying Files Remotely
Recipe 6.3 Copying Files Remotely
6.3.1 Problem
You want to copy files securely from one
computer to another.
6.3.2 Solution
For one file:
$ scp myfile remotehost:
$ scp remotehost:myfile .
For one file,
renamed:
$ scp myfile remotehost:myfilecopy
$ scp remotehost:myfile myfilecopy
For multiple files:
$ scp myfile* remotehost:
$ scp remotehost:myfile/* .
To specify another directory:
$ scp myfile* remotehost:/name/of/directory
$ scp remotehost:/name/of/directory/myfile/* .
To specify an alternate username for authentication:
$ scp myfile smith@remotehost:
$ scp smith@remotehost:myfile .
To copy a directory recursively (-r):
$ scp -r mydir remotehost:
$ scp -r remotehost:mydir .
To preserve file attributes (-p):
$ scp -p myfile* remotehost:
$ scp -p remotehost:myfile .
6.3.3 Discussion
The scp command
has syntax very similar to that of rcp or even cp:
scp name-of-source name-of-destination
A
single file may be copied to a remote file or directory. In other words, if
name-of-source is a file, name-of-destination
may be a file (existing or not) or a directory (which must exist).
Multiple files and directories, however, may be copied only
into a directory. So, if name-of-source is two or more files,
one or more directories, or a combination, then specify
name-of-destination as an existing directory into which the copy
will take place.
Both name-of-source and
name-of-destination may have the following form, in
order:
-
The username of the account containing
the file or directory, followed by "@". (Optional; permitted only if a hostname
is specified.) If omitted, the value is the username of the user invoking
scp.
-
The hostname of the host containing the
file or directory, followed by a colon. (Optional if the path is present.) If
omitted, the local host is assumed.
-
The path to the file or
directory. Relative pathnames are assumed relative to
the default directory, which is the current directory (for local paths) or the
remote user's home directory (for remote paths). If omitted entirely, the path
is assumed to be the default directory.
Although each of the fields is optional, you cannot omit them
all at the same time, yielding the empty string. Either the hostname (item 2) or
the directory path (item 3) must be present.
Whew! Once you get the hang of it, scp is pretty easy to
use, and most scp commands you invoke will probably be pretty basic. If
you prefer a more interactive interface, try sftp ,
which resembles ftp.
If you want to "mirror" a set of files securely between
machines, you could use scp -pr, but it has disadvantages:
-
scp follows symbolic links automatically, which you
might not want.
-
scp copies every file in its entirety, even if they
already exist on the mirror machine, which is inefficient.
A better alternative is rsync with ssh, which optimizes the
transfer in various ways and needn't follow symbolic links:
$ rsync -a -e ssh mydir remotehost:otherdir
Add -v and —progress for more verbose output:
$ rsync -a -e ssh -v --progress mydir remotehost:otherdir
[相关问题]
全局常用配置说明
模块常用配置说明
客户端常用参数
for Windows (cygwin)
远程shell模式和rsync守护进程模式
22.6. File Synchronization. Building Internet Firewalls, 2nd Edition
Hack 92 Mirroring Web Sites with wget and rsync. Spidering Hacks
Linux Security Cookbook - Recipe 1.16 Integrity Checking with rsync
Linux Security Cookbook - Recipe 1.6 Remote Integrity Checking
Linux Security Cookbook - Recipe 6.3 Copying Files Remotely
分享到:
相关推荐
适用于Centos7.9的rsync 工具安装包 rsync-3.1.2-10.el7.x86_64.rpm
rsync-3.1.2-4.el7.x86_64.rpm linux系统下rsync安装包
AIX文件同步复制工具RSYNC,rsync-3.1.2 for aix6.1。。。
rsync-3.1.3.tar.gz source收藏 rsync是linux系统下的数据镜像备份工具。使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH、rsync主机同步。
官方离线安装包,测试可用。请使用rpm -ivh [rpm完整包名] 进行安装
rsync-3.0.9.tar.gz linux 文件远程同步工具; 适用于centos,red hat
linux系统备份软件rsync-3.0.4.tar.gz
官方离线安装包,测试可用。请使用rpm -ivh [rpm完整包名] 进行安装
rsync-time-backup, 使用rsync的Time Machine风格 time备份这里脚本使用rsync提供 Time machine样式备份。 它创建文件和目录的增量备份到你所选择的目的地。 备份以一种方式进行结构化,这使得在任何时候都可以以...
用于服务器之间的数据同步和备份
多个服务器之间一个同步的不错选择。一般用户 linux unix等系统。
什么是 RSYNC-BPC? rsync-bpc 是 rsync 的定制版本,用作开源备份系统 BackupPC 的一部分。 rsync 的主要变化是添加了一个 shim 层(在子目录 backuppc 和 bpc_sysCalls.c 中),模拟访问文件系统的系统调用,...
linux系统文件实时同步工具,小巧好用,占用资源少。今天使用到了,在CSDN上没有找到,找到后即可上传,供大家使用
rsync的安装版本
例子1 $ docker run --name=rsync-sshd -p 2022:22 -e USERS=alice,bob -v rsync-data:/data:ro fphammerle/rsync-sshd$ docker cp alice-keys rsync-sshd:/home/alice/.ssh/authorized_keys$ docker cp bob-keys ...
Rsync version 3.2.3
Rsync version 3.0.7 has been released. This is a bug-fix release. See the release NEWS for the details of what changed since 3.0.6. The latest manpages are also available for both rsync and rsyncd....
rsync-3.0.8源代码 Rsync version 3.0.8 released March 26th, 2011 Rsync version 3.0.8 has been released. This is a bug-fix release.
rsync-3.0.9是最新版本的linux中文件同步工具
linux centos上用的文件同步工具 rpm版本的