Linux or UNIX securely copy files across a network computer

by on July 30, 2006 · 16 comments· last updated at August 24, 2007

Q. FTP is insecure, how do I securely copy files across a network computer? My network has Windows and Linux systems.

A. You need to use Openssh client and server technology to copy between two more network computers. You can also find free ssh client tools. scp copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.

Copy from Linux to Linux/UNIX system

Copy file called data.txt to ras.nixcraft.in Linux system (vivek is username):
$ scp data.txt vivek@ras.nixcraft.in:/home/vivek

Copy more than two files:
$ scp data.txt pic.jpg vivek@ras.nixcraft.in:/home/vivek
Copy /data directory and all files inside /data i.e. recursively copy entire directories:
$ scp -r /data vivek@ras.nixcraft.in:/home/vivek

Copy from Windows to Linux/UNIX system

You can download any one of the following free Windows SCP client

Just install above client and follow on screen instructions.



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 15 comments… read them below or add one }

1 Todd July 11, 2007 at 4:15 pm

Is there a way to copy multiple files to multiple servers? I’ve tried putting in a space and the location of the other server but no luck.

Reply

2 vivek July 11, 2007 at 7:01 pm

Todd,

You can copy multiple files to multiple servers using shell for loop:

SERVERS="user1@box1 user2@box2 user3@box3"
for s in $SERVERS
do
  scp file1 file2 ${s}:/path
done

Reply

3 Raj February 13, 2008 at 11:53 pm

you could also use it without a script.

for i in 1 2 3; do scp file1 file2 user@box$i; done

Reply

4 Raj February 13, 2008 at 11:55 pm

Actually it would be better if you could generate the ssh. keys and add it to your client machines.

Reply

5 Arun March 7, 2008 at 5:45 am

Is it possible to send password in the same line?
As in ftp we use, user/password@host . We cant disturb the remote machine for moving public key files. Thats why.

Reply

6 module November 30, 2008 at 11:51 am

I found this
http://toic.org/mscp/
to be very helpful when you need to scp files to multiple hosts.

Reply

7 laurent June 12, 2009 at 9:53 am

Hi vivek,

thank you for sharing all that in all the really goods post, article and tip/tricks. I’m not a sysadmin and your site has help me a lot those past moths for managing my server. Thanks !

Reply

8 D November 11, 2009 at 3:45 pm

yes! very nice site !! thank you!

Reply

9 shashwat singh February 22, 2010 at 9:31 am

hi
I am a new user to linux and just wanna noe how to share files in a network btw linux to linux machines or linux to windows
hoping for some quick response

Reply

10 vishal February 25, 2010 at 5:25 pm

When i try to copy a file from one server to another server using rcp command, i get error permission denied & if i use command scp, then it gives error connection lost whereas the server is pingable.

Reply

11 Shameem January 19, 2011 at 2:00 pm

Hi All,

This is all clear. But, if i want to copy single file to multiple destination using scp How can we do that ?

If possible, Can anybody send me syntax for that.

Thanks in advance.
Best Regards,
Shameem.

Reply

12 Kamal June 14, 2011 at 6:25 am

I connect to a network in three steps. Then how can I copy files to my machine home directory ?

Reply

13 nimi August 23, 2011 at 7:08 am

nice post thanks alot………:)

Reply

14 realrock October 4, 2011 at 9:44 am

source:root
Dest:user account

how copy a file from root mechine to user account in diff computer……..

Reply

15 Ratnam October 1, 2012 at 6:39 am

Hi

i wanna copy a file from Linux to windows by using rdesktop please help me

Thanks in advance

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , , , ,

Previous Faq:

Next Faq: