rsync - Linux Security Cookbook - Recipe 6.3 Copying Files Remotely
来源:互联网 发布:中国高尔夫网络电视台 编辑:程序博客网 时间:2024/06/05 16:10
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 onecomputer 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 commandhas syntax very similar to that of rcp or even cp:
scp name-of-source name-of-destination
Asingle file may be copied to a remote file or directory. In other words, ifname-of-source is a file, name-of-destinationmay be a file (existing or not) or a directory (which must exist).
Multiple files and directories, however, may be copied onlyinto a directory. So, if name-of-source is two or more files,one or more directories, or a combination, then specifyname-of-destination as an existing directory into which the copywill take place.
Both name-of-source andname-of-destination may have the following form, inorder:
The username of the account containingthe file or directory, followed by "@". (Optional; permitted only if a hostnameis specified.) If omitted, the value is the username of the user invokingscp.
The hostname of the host containing thefile or directory, followed by a colon. (Optional if the path is present.) Ifomitted, the local host is assumed.
The path to the file ordirectory. Relative pathnames are assumed relative tothe default directory, which is the current directory (for local paths) or theremote user's home directory (for remote paths). If omitted entirely, the pathis assumed to be the default directory.
Although each of the fields is optional, you cannot omit themall at the same time, yielding the empty string. Either the hostname (item 2) orthe directory path (item 3) must be present.
Whew! Once you get the hang of it, scp is pretty easy touse, and most scp commands you invoke will probably be pretty basic. Ifyou prefer a more interactive interface, try sftp ,which resembles ftp.
If you want to "mirror" a set of files securely betweenmachines, you could use scp -pr, but it has disadvantages:
scp follows symbolic links automatically, which youmight not want.
scp copies every file in its entirety, even if theyalready exist on the mirror machine, which is inefficient.
A better alternative is rsync with ssh, which optimizes thetransfer 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
- rsync - Linux Security Cookbook - Recipe 6.3 Copying Files Remotely
- rsync - Linux Security Cookbook - Recipe 1.16 Integrity Checking with rsync
- rsync - Linux Security Cookbook - Recipe 1.6 Remote Integrity Checking
- PHP cookbook, 2nd editon, Recipe 12.5
- Paleo Recipe Book - Brand New Paleo Cookbook
- Python Cookbook 第二版 汉化版 [Recipe 1.4] 对齐字符串
- Python Cookbook 第二版 汉化版 [Recipe 1.4] 对齐字符串
- Multiple errors occurred while copying the files
- Copying files from ASM to file system
- Multiple errors occurred while copying the files
- Multiple errors occurred while copying the files
- Windows Server 2003 Security Cookbook
- Linux Cookbook
- Connect to MySQL in Linux remotely
- rsync Usages For Transferring Files
- LINUX---RSYNC
- linux rsync
- linux - rsync
- ZJU 3080 ChiBi
- Axure RP Pro - 相关问题 - 在文本框中显示提示信息
- Palm pre上跑Android,智能手机越来越像兼容机
- Axure RP Pro - jQuery - "Bring to Front" Interaction
- 大学的纪念
- rsync - Linux Security Cookbook - Recipe 6.3 Copying Files Remotely
- 网址
- 2.6 如何发送简单请求
- 远程脚本
- 标准Ajax交互
- GET和POST
- rss(From 百度百科)
- sharepoint (From百度百科)
- 有关2009年春晚的几个文章,另网站被百度收录,自己庆祝一下!