Chinaunix首页 | 论坛 | 博客
  • 博客访问: 370687
  • 博文数量: 83
  • 博客积分: 2213
  • 博客等级: 大尉
  • 技术积分: 835
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-16 20:26
文章分类

全部博文(83)

文章存档

2015年(1)

2012年(1)

2011年(14)

2007年(20)

2006年(47)

我的朋友

分类: LINUX

2006-03-21 14:32:03

SCP(1)                    BSD General Commands Manual                   SCP(1)
NAME
     scp - secure copy (remote file copy program)
SYNOPSIS
     scp [-pqrvBC1246] [-F ssh_config] [-S program] [-P port] [-c cipher]
         [-i identity_file] [-l limit] [-o ssh_option] [[user@]host1:]file1
         [...] [[user@]host2:]file2
DESCRIPTION
     scp copies files between hosts on a network.  It uses ssh(1) for data
     transfer, and uses the same authentication and provides the same security
     as ssh(1).  Unlike rcp(1), scp will ask for passwords or passphrases if
     they are needed for authentication.
     Any file name may contain a host and user specification to indicate that
     the file is to be copied to/from that host.  Copies between two remote
     hosts are permitted.
     The options are as follows:
     -c cipher
             Selects the cipher to use for encrypting the data transfer.  This
             option is directly passed to ssh(1).
     -i identity_file
             Selects the file from which the identity (private key) for RSA
             authentication is read.  This option is directly passed to
             ssh(1).
     -l limit
             Limits the used bandwidth, specified in Kbit/s.
     -p      Preserves modification times, access times, and modes from the
             original file.
     -r      Recursively copy entire directories.
     -v      Verbose mode.  Causes scp and ssh(1) to print debugging messages
             about their progress.  This is helpful in debugging connection,
             authentication, and configuration problems.
     -B      Selects batch mode (prevents asking for passwords or
             passphrases).
     -q      Disables the progress meter.
     -C      Compression enable.  Passes the -C flag to ssh(1) to enable com-
             pression.
     -F ssh_config
             Specifies an alternative per-user configuration file for ssh.
             This option is directly passed to ssh(1).
     -P port
             Specifies the port to connect to on the remote host.  Note that
             this option is written with a capital `P', because -p is already
             reserved for preserving the times and modes of the file in
             rcp(1).
     -S program
             Name of program to use for the encrypted connection.  The program
             must understand ssh(1) options.
     -o ssh_option
             Can be used to pass options to ssh in the format used in
             ssh_config(5).  This is useful for specifying options for which
             there is no separate scp command-line flag.
     -1      Forces scp to use protocol 1.
     -2      Forces scp to use protocol 2.
     -4      Forces scp to use IPv4 addresses only.
     -1      Forces scp to use protocol 1.
     -1      Forces scp to use protocol 1.
     -1      Forces scp to use protocol 1.
     -1      Forces scp to use protocol 1.
     -1      Forces scp to use protocol 1.
     -2      Forces scp to use protocol 2.
     -4      Forces scp to use IPv4 addresses only.
     -6      Forces scp to use IPv6 addresses only.
DIAGNOSTICS
     scp exits with 0 on success or >0 if an error occurred.
AUTHORS
     Timo Rinne <> and Tatu Ylonen <>
HISTORY
     scp is based on the rcp(1) program in BSD source code from the Regents ofthe University of California.
     the University of California.
SEE ALSO
     rcp(1), sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1),
     ssh_config(5), sshd(8)
BSD                           September 25, 1999                           BSD
~
~
~
~The command to secure copy a file in linux is scp.

How do I copy a file from one computer to another?
The general form is:

  # scp source target
an example:
  # scp joeshmoe@miles.shadlen.org:matlab/mfile.m matlab/

This will copy the file mfile.m from the matlab directory on miles to the directory matlab on whatever machine the user is on currently. If there is no directory matlab in the current directory, an error message will be returned. Either type out the whole pathway (~/matlab - if the directory matlab is in your home directory) or the pathway relative to your current directory (./ for current directory). The name of the file can also be printed in the target, which is useful if you want to give the file a new name in its new place. Let's say you wanted to copy the file example.m from your matlab directory (which is in your current directory) on the computer you are on, change the name to silly.m and place it in a directory called unfinished in your home directory on miles.

  # scp example.m joeshmoe@miles.shadlen.org:unfinished/silly.m
The command to synchronize two directories (or two directory trees) so that they look the same is called rsync.

How do I sync two directories?
To update the files on a target to reflect changes you have made at a source, use

  # rsync -avub -e ssh source target 
where source and target are written according to scp syntax. For example, given ~/matlab/project/ directories on both merleau and localhost, you can type
  # rsync -avub -e ssh ~/matlab/project merleau.rprc.washington.edu:matlab/ 
to update all the files in project on merleau to reflect the changes you have made to them on localhost. If the directory project does not exist on merleau inside the directory matlab, rsync will create it. And if you had typed matlab/project/ as the target, rsync would create another directory project inside the directory project. It is important whether there is a slash at the end of the source directory. A trailing / on a source name means "copy the contents of this directory". Without a trailing slash it means "copy the directory". The -b option copies all of the backup files as well, which can lead to excessive copies of backups, since sync used with these options does not delete any files. Rsync, used with this syntax, will not overwrite newer files in the target.

A little thought will convince you that a complete synchronization may require doing a rsync in both directions.

For more information,

  #  man rsync
If you have not installed the rsync package, you can get it from by following the trail to your appropriate linux distribution, eg rsync-2.4.4-1.i386.rpm for Red Hat 7.0.
~
~
~
~
~
~
~
~
阅读(2407) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~