Saturday, April 3, 2010

Copying files from one host to another with scp command

Best Reference

http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/04eaff076bce249dca256fb6007f53e5?OpenDocument

Copy entire folder with all files and subfolders
user@user:~$ scp -r /var/www/localdir/ user@192.168.10.150:/var/www/


In windows
Putty and pscp are excellent tools for ssh and scp operations in windows os.
Download putty and pscp softwares from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
They are self executable files so no need to install those just place in some folder ex: c:\programfiles\putty folder and set the path in command prompt.

open command prompt (DOS Prompt)from start -> run -> cmd

set PATH=C:\path\to\putty\directory;%PATH%

So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type:

pscp fred@example.com:/etc/hosts c:\temp\example-hosts.txt

To send (a) file(s) to a remote server:

pscp [options] source [source...] [user@]host:target

So to copy the local file c:\documents\foo.txt to the server example.com as user fred to the file /tmp/foo you would type:

pscp c:\documents\foo.txt fred@example.com:/tmp/foo

You can use wildcards to transfer multiple files in either direction, like this:

pscp c:\documents\*.doc fred@example.com:docfiles
pscp fred@example.com:source/*.c c:\source

Copy entire folder from remote server to local computer along with files and subfolders
pscp -r user@example.com:source/* c:\source

Ref : http://www.jfitz.com/tips/ssh_for_windows.html

0 comments: