dd over ssh



dd is a command-line utility for Unix and Unix-likeoperating systems, the primary purpose of which is to convert and copy files.

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line login and remote command execution, but any network service can be secured with SSH.

The point is, you know what your target is, this tutorial tries to be as short as possible.

Imagine you have 2 server, A and B, both equipped with disk sda and sdb. To make it simple, just ignore the size problem for now.

To copy from /dev/sda in server A to /dev/sdb in server B, use this command on server A.

dd if=/dev/sda | ssh root@server2 "dd of=/dev/sdb"

To copy /dev/sdb in server A to block file /tmp/file.img at server B, use this command on server A.

dd if=/dev/sda | ssh root@server2 "dd of=/tmp/file.img"

Need progress bar? use pv. Install it, here’s the guide for ubuntu/debian

apt-get update && apt-get install pv

Then pipe it to pv.

dd if=/dev/sda | pv | ssh root@server2 "dd of=/tmp/file.img"

Feeling poor on bandwidth? Make use of gzip!

dd if=/dev/sda | pv | gzip | ssh root@server2 "gunzip | dd of=/tmp/file.img"

That concludes everything.



Share Button
Published
Categorized as Tutorial

By Rinaldo Jonathan

Admin of this site. Artis papan PCB. #zoneRinaldo #Controllerism Studio Demon, Stage Angel, Sleepy Developer, Smoke free. Kalkud SHS 2012, PCR G15.

Leave a Reply

Verified by ExactMetrics