Tay Ray Chuan home archive

transferring binary data with base64 and paste bins

Sun, 25 Sep 2011 16:37:18 +0800 | Filed under unix, recipe

Nowadays we're pampered with many data transfer methods - from the physical (flash drives), to the "cloud" (Dropbox).

But if you are working with ssh, your options are restricted. The recommended way of transferring data is with scp/sftp, but I find it quite a hassle: you've got to open a new terminal, then figure out the source and target paths; not to mention recalling the right options to pass to scp/sftp.

Below is a lazy alternative for non-sensitive (binary) data:

$ # on the source machine, base64-encode the binary data so that we get pastable-text
$ openssl enc -base64 <file >enc.out

$ # paste the contents of enc.out into a paste bin provider...

$ # on the target machine, download the raw paste
$ wget ...

$ # decode it
$ openssl enc -base64 -d <paste.txt >file

You might want to fingerprint the data for verification.

blog comments powered by Disqus