There was a problem loading the comments.

SCP Tutorial

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
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/.


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:
[user@server ~]$ scp -P port 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:
[user@server ~]$ scp -r -P port 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:
[user@server ~]$ scp -P port username@hostA.com:filename .
(copies into current directory on hostB)

[user@server ~]$ scp -r -P port 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:
[user@server ~]$ scp -P port username@hostA.com:/folder/dir/filename .
(copies into current directory on hostB)

[user@server ~]$ scp -r -P port 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):
[user@server ~]$ scp -r -P port folder username@hostA:/home/httpd/

[user@server ~]$ scp -P port username@hostA.com:/folder/dir/filename /home/tmp/


Does your host impose a resource control over ssh?
Just nice any/all of the above statements with a prefix like

[user@server ~]$ nice -n +19

You can change the number 19 to any value below your hosts resource limit.

Share via
Thank you for your feedback on this article.

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net