Pages

Thursday, November 1, 2012

How to use SCP command ?

Copying files using SCP command:


SCP ~ Secure Copy, which is used for copying files between local to remote or remote to local or remote to remote. These transfers are based on SSH ~ Secure Shell protocol

SCP options:

-p     preserves the modification and access times, as well as the permissions of the source-file in the destination-file

-P     port, specify only if it is other than the default port 22

-q     does not display the progress bar

-r      recursive, copies the contents of the source-file (directory in this case) recursively

-v     displays debugging messages


Examples:

Copying file to host:
scp /tmp/file_name user@host:/directory/TargetFile

 scp *.log user@remote.server.com:/home/user/
That is going to copy all files with .log extension to the folder /home/user in the remote.server.com host

Copying file from host:
scp user@host:directory/file_name TargetLocation or Folder



scp -r user@host:directory/SourceFolder TargetFolder


If the remote host ssh uses 44, you should specify (other than default port 22) in the command.  
scp -P 44 user@host:directory/SourceFile TargetFile

From a remote host to another remote host:
 scp user1@host1:/tmp/file_name user2@host2:/home/user2/

**  Important:   Don’t try tab button for auto completion of path when using remote host path. If you try ‘tab’ it will take the local host path only. Hence I request you to remember the actual path/location at remote host and use it.


Suggestions are always welcome..!  Without signing also you can send your comments.


No comments: