I need to transfer disk image from old server that has only port 22 open and it has too weak cpu for any reasonable ssh transfer speed. I tried:

  • ssh - painfully slow, beyond practicality
  • rsync - can't send block device
  • rsh - I can't seem to find option to change server port to 22
  • nc like below:


nc <ip> 22 > /backup/path/sda.img


dd if=dev/sda bs=8M | nc -l -p 22

but it doesn't seem to work as expected (at all). Other ports can't be opened and no additional software can be installed on server and server has blocked outgoing connections.

I'm running out of options ._.

  • Why a disk image? Done well, you just tar the filesystem via nc Feb 22, 2018 at 20:14
  • 1
    Port 22 is almost certainly ssh. And why are you assuming slow transfer speeds a CPU-limited? You have no evidence that any other protocol goes faster. The sooner you get started, the sooner it'll be done.... Feb 22, 2018 at 20:24
  • Do you get any error messages? Did you mean to type /dev/sda rather than dev/sda? (Those would refer to the same file if your current directory is /.)
    – dhag
    Feb 22, 2018 at 20:27
  • 1
    In the end I managed to use nbd and it works. 22 was exactly because it was ssh so I could shut down ssh daemon and get the only port open in firewall. Indeed it's not bottlenecking on CPU. I don't know what is bottleneck with ssh but connection between machines is 1G and disks are much faster than 20MB/s. I checked that. No there was no error with nc it just didn't send anything. When I typed something in client nc it appeared on server screen also when I typed on server it didn't appear on client so pipe seemed to work but disk data was not transferred properly idk why. 0 disk i/o
    – Lapsio
    Feb 22, 2018 at 20:49
  • 2
    Have you tried using a very weak but very fast cipher for SSH? Only do this if you either don't care about security or are extremely confident that only you are on the wire: ssh -c arcfour.
    – DopeGhoti
    Feb 22, 2018 at 21:12

1 Answer 1


Try this :

Remote side :

# nc -l -p 22 > sda.img

Client side :

# dd if=/dev/sda bs=8M | nc -w 3 remote_host 22
  • But I wanted the other way around. copy sda from remote host to image on local machine. Because server has blocked outgoing connections it can't nc to workstation with backup NAS hooked up. So device that has original /dev/sda has to use nc -l, not the other one
    – Lapsio
    Feb 23, 2018 at 21:07

You must log in to answer this question.

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