Re:File Transfer with SSH, Tee, and Base64
by tssva on Thursday September 17, 2020 @08:03PM
(#24511442)
It certainly isn't a complete cross platform solution but to address the inconsistent options problem and some of the availability issues openssl could be used instead.
... | openssl enc -base64" | openssl -base64 -d | ...
You can implement base64 as a shell script using the above techniques, and do so without relying on awk, which isn't always available. If od(1) isn't available you can use dd(1) to extract stdin byte-by-byte and convert with printf(1), but that gets really slow. I've written an implementation that only needs an 8-bit-clean but otherwise POSIX compliant shell, printf, and either dd or od. It doesn't need tr, but it's even slower without it. It just converts the bytes to decimal and uses plain shell arithmetic for the primitive encoding and decoding, similar to how it would be done in any language.