Quick host-to-host transfer

09 Apr 2008

From the openSUSE weekly newsletter:

Quick host-to-host transfer

Tired of setting up an ftp server just to transfer some files from one host to another? You don't trust your buddy to give him an account to your machine for ssh? Don't want to enter a password on someone else's machine? Look no further! Here is how to copy files from host2 to host1 in the shell:

host1:$ netcat -lvp 12345 | tar -xv

host2:$ tar -cv file [files...] | netcat -v IP_of_host1 12345

You can also use this in combination with dd to copy e.g. partitions:

host1:$ netcat -lvp 12345 >part_xyz.img

host2:$ netcat -v IP_if_host1 12345

Geek facts about netcat:

  • by many considered one of the most useful network utilities
  • available for install with the known methods
  • when telnet host port is used to test a TCP connection or talk to some text based server, netcat host port is the tool actually designed to do that.
  • doubles as a port scanner
  • on some systems and busybox, just short nc

blog comments powered by Disqus