Tuesday, October 27, 2009

Copying files between Solaris/Linux Servers

scp is a command that can be used for Remote copying of files [to and from] on Solaris/Linux. It uses ssh to transfer data between 2 systems and hence is safer as compared to ftp.

Syntax for copying files TO a server
=======================================
scp /source_dir/file_name user@target_box:target_dir/

For example
scp /vipul/sample.txt root@ajooba:/
will copy the sample.txt to a server name ajooba's root [/] directory.

The another example will copy the entire directory from the source directory to target directory
scp -r /export/source_dir/ root@aconite:/target_dir

Similiarly, scp can be used to copy files FROM a server

Copying file from host:
scp user@Source_Machine:directory/ TargetFileName

Note -- If the root is being used to copy the files please note that root have the following entry marked as yes in /etc/ssh/sshd_config
PermitRootLogin yes
The scp may thorw permission denied exception in case the permission is set to No



Reference taken from -- http://en.wikipedia.org/wiki/Secure_copy#SCP_program

No comments: