Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Fred

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

SCP Secure CP

// description of your code here

   1  
   2  Scp is a utility which allows files to be copied between machines. Scp is an updated version of an older utility named Rcp. It works the same, except that information (including the password used to log in) is encrypted. Also, if you have set up your .shosts file to allow you to ssh between machines without using a password as described in help on setting up your .shosts file, you will be able to scp files between machines without entering your password.
   3  Usage of the Scp Command
   4  
   5  The general form of the command is:
   6  
   7  	% scp source-specification destination-specification
   8  	
   9  
  10  where source-specification indicates which file or directory is to be copied, and destination-specification indicates where the copied material is to be placed.
  11  
  12  Either the source or the destination may be on the remote machine; i.e., you may copy files or directories into the account on the remote system OR copy them from the account on the remote system into the account you are logged into.
  13  
  14  Example:
  15  
  16  	% scp myfile xyz@sdcc7:myfile
  17  	
  18  
  19  To copy a directory, use the -r (recursive) option. Example:
  20  
  21  	% scp -r mydir xyz@sdcc7:mydir
  22  	
  23  
  24  File Specification Formats
  25  
  26  The format for the remote specification (source or destination) is:
  27  
  28  	user@machine:filename
  29  	
  30  
  31  where filename is the name (path) of the file or directory relative to the home (login) directory on the remote system.
  32  
  33  The format for file specification on the local system is just:
  34  
  35  	filename
  36  	
  37  
  38  where fname is the name (path) relative to the current working directory on that system.
  39  How scp is similar to cp
  40  
  41  Just like the cp command, scp will overwrite an existing destination file. In addition, if the destination is an existing directory, the copied material will be placed beneath the directory.
  42  Examples of remote file copies
  43  
  44     1. While logged into xyz on sdcc7, copy file "letter" into file "application" in remote account abc on sdcc3:
  45  
  46        	% scp letter abc@sdcc3:application
  47        	
  48  
  49     2. While logged into abc on sdcc3, copy file "foo" from remote account xyz on sdcc7 into filename "bar" in abc:
  50  
  51        	% scp xyz@sdcc7:foo bar
  52  
  53        	
  54  
  55     3. While logged into account xyz on sdcc7, copy file "garfield" from subdirectory "comix" into filename "fatcat" in subdirectory "stuff" in remote account abc on sdcc3:
  56  
  57        	% scp comix/garfield abc@sdcc3:stuff/fatcat
  58        	
  59  
  60     4. While logged into account abc on sdcc3, copy file "garfield" from subdirectory "comix" of account xyz on sdcc7 into subdirectory "stuff" with the same name "garfield":
  61  
  62        	% scp xyz@sdcc7:comix/garfield stuff
  63        	
  64  
  65     5. While logged into account abc on sdcc3 , copy subdirectory "Section" into a new subdirectory called "Section" in existing subdirectory "Chapter" in account xyz on sdcc7:
  66  
  67        	% scp -r Section xyz@sdcc7:Chapter
  68        	
  69  
  70     6. From account abc on sdcc3, copy entire account to ir123 on iacs5. This needs to be done from the parent directory of the account to be moved.
  71  
  72        	% cd
  73        	% cd ..
  74        	% scp -r abc ir123@iacs5:abc
  75        	
  76  
  77  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS