What is the simplest and most versatile way to send files over the network to other computers? By that I mean computers that other people are using at the moment. I don't think SSH works if the computer has an active session open.

So far I am using netcat, which works alright. But are there any other simple ways to do this? One problem I have with netcat, is that the receiver needs to know the file ending and has to come up with a name for the stream.

  • 1
    If you want to keep using netcat you can send a tar archive and extract it on the fly. That will solve the file name issue and it's more flexible. But in the end I guess scp or rsync is the easier option.
    – Marco
    Apr 21, 2015 at 9:00
  • How would sending a tar and extracting it on the fly work?
    – TomTom
    Apr 21, 2015 at 9:02
  • 1
    I suppose that would be netcat hostname | tar -x in the directory where you want to put the files. Apr 21, 2015 at 10:15
  • 10

5 Answers 5


You're complicating your life needlessly. Use scp.

To transfer a file myfile from your local directory to directory /foo/bar on machine otherhost as user user, here's the syntax: scp myfile user@otherhost:/foo/bar.

EDIT: It is worth noting that transfer via scp/SSH is encrypted while transfer via netcat or HTTP isn't. So if you are transferring sensitive files, always use the former.

  • Don't I need a password for scp of the user account?
    – TomTom
    Apr 21, 2015 at 8:57
  • 2
    No, you don't need a password if you use public key authentication
    – YoMismo
    Apr 21, 2015 at 13:22
  • 9
    Ok, if you want to be picky, let's state that you have to authenticate as user@otherhost.
    – dr_
    Apr 21, 2015 at 13:31
  • 1
    Also, as a simplification, if your username is the same on both machines, you can exclude the username. It'll still ask you for a password when applicable, though.
    – Sildoreth
    Apr 21, 2015 at 20:17
  • 1
    Such a no brainer, yet didn't cross my mind at all! Thanks!
    – aksh1618
    Nov 5, 2021 at 5:58

If you're happy with netcat you can work around the file name issue by intruducing tar. This also simplifies sending multiple files at once as well as sending directories.

On the sending side use:

tar cf - <files> | nc <host> <port>

And on the receiving side:

nc -l <port> | tar x

Another solution would be to use rsync or scp.

  • I usually add -q2 to the sending netcat as well, to make it shut down the connection at the end of the stream. Apr 21, 2015 at 16:59
  • I fail to understand why this should be required. It does shut down automatically without the -q option.
    – Marco
    Apr 21, 2015 at 17:40
  • That depends on which netcat implementation you use. There are implementations that only close one direction of the TCP stream when stdin closes, because the other direction may still be active. Apr 21, 2015 at 18:40
  • tar | ssh tar also works very nicely in cases where scp falls down and rsync isn't available.
    – hobbs
    Apr 22, 2015 at 7:15

You can also try

python -m SimpleHTTPServer 8180

It will serve the files in directory in which it executed over HTTP, you can access it via Browser.

  • Or use darkhttpd when being dissatisfied with performance.
    – TNW
    Apr 21, 2015 at 20:59
  • 3
    For Python 3: python3 -m http.server <port>.
    – dotancohen
    Apr 22, 2015 at 6:17
  • See here for more information about this option: askubuntu.com/a/95607/42073 May 12, 2016 at 18:59
  • Thanks! Perfect to getting some files onto a Windows test system Jan 25, 2019 at 0:46

Of course ssh works if another session is open. You can just do

ssh user@host cat /path/to/file.tar  > localfile.tar

Or, to copy to your local directory:

scp user@host:/path/to/file.tar .
  • Is it possible the other way around e.g. ssh lubuntu '>newfile.txt' <file.txt ?
    – heemayl
    Apr 21, 2015 at 10:20
  • 1
    @heemayl yes, to cat into a remote file, you would do cat local.file | ssh user@host "cat > remote.file", or ssh user@host "cat > remote.file" < local.file.
    – terdon
    Apr 21, 2015 at 10:34

If both hosts are in the same LAN, you can use woos.

It's extremly simple in usage.

If sender and receiver are ANYWHERE in the internet and you have to transfer BIG FILES, you should install F*EX: http://fex.belwue.de/index.html

  • 1
    basic scp is also extremely simple, and a tool which is actually distributed, trusted and used by millions people, unlike these home-made tools which appear to be promoted by their author.
    – Jack Wasey
    Jul 19, 2018 at 13:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .