@ wrote... (6 years, 1 month ago)

Depending on the hardware involved, you can dramatically speed up an ssh pipe by changing the encryption type, or turning off compression.

For example, if you're trying to clone a disk from a machine with a weak cpu, and that disk contains mostly media files (non-compressible avi's, mp3's or jpeg's) then trying to compress the stream will be a waste of cpu time. Also, if you're using a strong encryption scheme, then that is also more taxing on the cpu.

So, if security isn't the highest priority then you can potentially speed up a slow disk clone quite easily.

My sender was an old machine so I wanted to clone the disk to a new faster machine.

# my original .ssh/config contained:
Compression yes
# naive/default sender
dd if=/dev/sdb | ssh other_host dd of=/dev/sdb

This was ridiculously slow, I was getting roughly 10MB/s on a gigabit network.

# "smart" sender
dd if=/dev/sdb | ssh -o Compression=no -o Cipher=arcfour other_host dd of=/dev/sdb

This brought the transfer up to 60MB/s, the speed of the hard drive on the slow machine. arcfour is a weak but simple (ie: fast) encryption cipher.

To make this permanent, you can change your .ssh/config to include:

# my new .ssh/config contains
Compression no
Ciphers arcfour,aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc

Or if you don't need the fancier abilities of ssh (multiple hops, encryption, etc) then just use netcat.

# receiver
nc -l 12345 | dd of=/dev/sdb
# sender
dd if=/dev/sdb | nc other_host 12345

But this is a bit more annoying as you have to manually run a command on the other_host and you have to make sure that of=something of the receiver matches if=something of the sender.

Category: tech, Tags: linux, ssh
Comments: 0
Click here to add a comment