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. Usage of the Scp Command The general form of the command is: % scp source-specification destination-specification where source-specification indicates which file or directory is to be copied, and destination-specification indicates where the copied material is to be placed. 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. Example: % scp myfile xyz@sdcc7:myfile To copy a directory, use the -r (recursive) option. Example: % scp -r mydir xyz@sdcc7:mydir File Specification Formats The format for the remote specification (source or destination) is: user@machine:filename where filename is the name (path) of the file or directory relative to the home (login) directory on the remote system. The format for file specification on the local system is just: filename where fname is the name (path) relative to the current working directory on that system. How scp is similar to cp 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. Examples of remote file copies 1. While logged into xyz on sdcc7, copy file "letter" into file "application" in remote account abc on sdcc3: % scp letter abc@sdcc3:application 2. While logged into abc on sdcc3, copy file "foo" from remote account xyz on sdcc7 into filename "bar" in abc: % scp xyz@sdcc7:foo bar 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: % scp comix/garfield abc@sdcc3:stuff/fatcat 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": % scp xyz@sdcc7:comix/garfield stuff 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: % scp -r Section xyz@sdcc7:Chapter 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. % cd % cd .. % scp -r abc ir123@iacs5:abc
You need to create an account or log in to post comments to this site.