Using 'scp' to copy files securely (a.k.a. command-line Secure FTP)

Using 'scp' to copy files securely (a.k.a. command-line Secure FTP)
If you are in a UNIX environment and need a quick and secure way to copy files I suggest using scp from the command-line. SSH and OpenSSH provide the scp application, which allows you to connect and transfer files on servers running an encrypted FTP service. (ssh daemon)
If you are looking for an X windows GUI application, you may want to try out http://gftp.seul.org/.
Scp is already installed on the UW Dante and Homer servers and if you know the right directories it will even work with Windows secure FTP servers.
Here is how scp works :( Note the use of periods; they are essential!!)
1) To copy a file from hostB to hostA, while logged in to hostB:
bash$ scp filename username@hostA.com:.
(copies file to user's home dir on hostA machine, because of the period after the colon)
2) To copy a folder from hostB to hostA, while logged in to hostB first cd to the directory on HostB which contains the folder you want to copy:
bash$ scp -r folder username@hostA.com:.(creates new folder if the folder does not exist, again in user's home directory)
3) To copy a file from hostA to hostB, while logged in to hostB:
bash$ scp username@hostA.com:filename .
(copies into current directory on hostB)
bash$ scp -r username@hostA.com:folder .
(copies whole folder into current directory on hostB)
4) To copy a file or folder within a folder from hostA to hostB, while logged in to hostB:
bash$ scp username@hostA.com:/folder/dir/filename .
(copies into current directory on hostB)
bash$ scp -r username@hostA.com:/folder/dir .
(copies whole folder into current directory on hostB)
5) Instead of using the '.' to designate files to be copied to a home directory or the current working directory you can give scp an actual path (assuming you have write permissions):
bash$ scp -r folder username@hostA:/home/httpd/
bash$ scp username@hostA.com:/folder/dir/filename /home/tmp/

No comments:

Post a Comment