Data Copy Over SSH 2


Need to transer a whole disk image to another computer over SSH?

Just:
dd if=/dev/sda | ssh user@host "dd of=/directory/imagefile"

or with compression:
dd if=/dev/sda | bzip2 |ssh user@host "dd of=/directory/imagefile"

or with compression on the receiving side:
dd if=/dev/sda | ssh user@host "bzip2 | dd of=/directory/imagefile"

This example can be expanded easily as:
cat filename |ssh user@host "dd of=/directory/filename"

also works quite fine.
Actually anything that can produce output stdout can be piped to another computer.

mysqldump:
mysqldump mysql -p | ssh user@host "lzma -2 | dd of=/directory/tst.lzma"

or tar:
tar zcvf - dir-to-be-tarred/ | ssh user@host "dd of=/directory/tst.tar.gz"

Life of a piper man is amazing, isn’t it?

Leave a comment

Your email address will not be published. Required fields are marked *