Saturday, March 8, 2008

Using scp To Safely Transfer File

scp is safer compared to rcp, as it encrypts the whole file. However, it will cause a considerable load on the server.
Scp functions pretty much like cp command used for copying files.

Here is the format for scp command:

$ scp user@source.hostname:source_filename user@destination.hostname:dest_dir/dest_filename

Most of the time, there’s no need to put the hostname if you’re copying the local file.

$ scp source_filename user@destination.hostname:dest_dir/dest_filename

There is also no need to put user@, if the source and the destination is the same machine.

Some more examples:

You are logged into abigail and transferring a file from benjamin to abigail. You’re in your home directory in abigail, the file.dat is the filename.

abigail$ scp username@benjamin.hostname:file.dat .

Transferring file.dat in your current directory on benjamin to abigail in the data directory and not changing the name of the file.

benjamin$ scp file.dat username@abigail.hostname:data/


The following is the same of above but changing the file.dat name at the destination directory

benjamin$ scp file.dat username@abigail.hostname:data/


You’ll be asked for your password, like you’re logging in to the remote machine. The tranfer will run right after the correct password keyed-in.



No comments: